xlsx-calc
xlsx-calc copied to clipboard
AVERAGE function does not behave correctly with no rows
If i use a formula of FLOOR(IF(ISERROR(AVERAGE(Sheet1!D2:D)),0,AVERAGE(Sheet1!D2:D)),1)
, IE floor of average of a column, or zero if column is an error, the result I get after running the calculation is {t:"n", v:NaN, f:(above), w:"0"}
.
The Average function returns a NaN which is not handled by the ISERROR function surrounding it because divide by zero does not throw an exception in JS, while the same operation would give #DIV/0!
, and/or be caught by ISERROR in other spreadsheet programs
I can get the result i need by changing it to ISNUMBER instead of ISERROR, but i believe ISERROR + AVERAGE still has incorrect behaviour