Length of list not working?

AstroZack shared this question 2 years ago

Someone please help me figure out what I'm doing wrong. I want to count the number of non-empty cells in a particular range in Column A. However, Column B uses Column A in its calculations. The cells in B are fixed so my students can't accidentally erase the formulae.

I am trying to calculate/count the non-empty cells in Column A like this:

l3 = Length(Flatten(l1)) where l1 is the range of cells from A2 to A116.

I keep getting 115. I've tried changing the formula in a number of ways but the result is always 115 - even when it logically can't be:

l3 = Length(Flatten(l1 = 0)) Answer: 115

l3 = Length(Flatten(0 - l1 < 0)) Answer: 115

l3 = Length(Flatten(0 - l1 > 0)) Answer: 115

I've also tried Length(Flatten({A2:A200<0})) and Length(Flatten({A2:A200>0})) but they also yields 115.

It seems like is must be because Geogebra is automatically putting a ? in each empty cell in Column A, but I don't know how to get around it. I need this to behave properly because there are certain features that I don't want to appear until the students have a minimum number of data points.

Can someone please help me solve the mystery, because I'm completely stumped.


Comments (2)




or (better) if you do not know exactly how long at maximum, but certainly smaller than...




If an object does not appear in the algebraview (not even as auxiliary) then it would be empty/not exists

it is not possible in GGB script to test an object/cell for "empty" or "not exits".

Undefined == ? is not the same as empty/not exists

Testing an object for "undefined" is possible with "! IsDefined(<object>)"

Referencing non-existing objects is basically not possible in ggb, not even in the spreadsheet. Therefore, GGB automatically creates an object for a cell with the value "?" == undefined when an empty cell is referenced from another cell (only inside the spreadsheet)


Perfect! That worked beautifully! Thank you so much. I would have been scratching my head for a very long time trying to figure that one out.


© 2023 International GeoGebra Institute