I've searched all over but I can't find any examples similar to mine. I'm working with an Excel-like JavaScript control (that is compatible with Excel formulas), and I need to be able to write a formula that differentiates between sums that are null (a valid use case) and actual sums that amount to 0.
For instance, you can see the highlighted row below is the sum row. By using JavaScript, I am able to check if a sum is null or actually 0 and assign the values appropriately.
However, I am unable to replicate this behavior in the Excel-like JavaScript control, because we use formulas, and all formulas must evaluate to a value, rather than null. The sum equals 0 when values are empty:
The JavaScript code is littered with formulas like the one below, which is setting the sum row equal to the sum of a range:
sheet.getCell(i, 3).formula("=(D4+D5+D6+D7+D8+D9)");
How can I modify this formula to only return 0 if the sum is legitimately 0, and an empty string otherwise?
ISBLANK
? E.g.=IF(AND(ISBLANK(D4),ISBLANK(D5),ISBLANK(D6),ISBLANK(D7),ISBLANK(D8),ISBLANK(D9)),"",SUM(D4:D9))
– CactusCake