INDEX returns number on empty cell

Hi!
Regardless of the cell format on the input cells or the cells with the formula, the INDEX function returns a number on empty input cells (see attached file).
As a workaround I added an empty string to the result of the INDEX function {like =""&INDEX(input1;$C3;1) }.
Is there a better way to get an “empty string” instead of the number when the input cell is empty?
INDEX empty cell.ods (13.3 KB)

Not much better, except that it returns a result of the same type as the input cell (text or string):
=IF(ISBLANK(INDEX(input1,$C3,1)),"",INDEX(input1,$C3,1))
Or using the recent LET function:
=LET(res,INDEX(input1,$C3,1),IF(ISBLANK(res),"",res))

1 Like

Since Calc (like Excel) is a spreadsheet, the historical choice between returning the number 0 or an empty string was decided in favor of a number. :slight_smile:
Concatenation with an empty string is a normal solution.

The output of ‘0’ is ambiguous in three ways: as the NUMBER “zero”, as logically “false”, or as a replacement for a missing cell content. You have to be aware of its meaning and how to handle it. The fact that an empty cell is treated equally to its NUMBER “zero” entry is a handicap! An empty cell is like an undefined entry, i.e. anything between “nothing” and “infinity”, an unforgivable mistake by any programmer. Some CALC functions ignore an empty cell! For other functions, you can specify whether to ignore empty cells or evaluate them as zero, which is crucial, for example, when calculating the average of the contents of several cells.


My tip: Never trade with a seemingly empty cell, because you don’t always know what’s actually inside it.