Returning An Empty Value In LibreOffice Calc
I learned a cool trick today. If you need a formula to return an empty cell, say in an IF formula, simply use {} as the parameter. For example:
IF(A1=B1,"True",{})
This will return an empty cell when A1 and B1 are not equal. This does not remove the formula, it simply returns nothing, or NULL in computer parlance.
What is really happening here is that the formula is returning an empty array, or an array with no objects. This then gets treated as an empty cell by Calc for other formulas. Empty cells are treated as empty strings OR 0 depending on the context.
If I had returned an empty string ("") or a 0 in my formula it would not have worked the same. I have a few formulas in the sheet I am working on that treat empty cells as empty strings in some cases and zeroes in others. This was sloppy on my part and bad programmatic design, but the tech debt was already there.
For clarity, the formula ISBLANK({}) will return TRUE, while ISBLANK(0) and ISBLANK("") will return FALSE.
Comments