You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Autosum, but with some blank formulas. I'll explain...

Howdy! So, I have a column (column D if you must know!). Each cell in each row in column D is a formula, like this


(C3-B3), (C4-B4), and so on, for each row.


I then get a number in that cell, for each row. Then, I need a sum total for column D. BUT, I haven't entered values for all the rows yet, so I get an error in the SUM cell (a red triangle with an exclamation. Would that be called a "red bang"?). BTW, none of those cells in column D show errors; they show as 0 (zero).


If I limit my summing to just the filled-out rows, it works perfectly.


Is there a way to keep a running total for column D, given this scenario?


TIA

Mac mini, macOS 14.6

Posted on Aug 20, 2024 6:25 PM

Reply
Question marked as Top-ranking reply

Posted on Aug 20, 2024 11:57 PM

How about changing the formula from "C3-B3" to "IF(OR(ISBLANK(B3), ISBLANK(C3)), "", C3−B3)"?

7 replies

Aug 21, 2024 1:51 PM in response to shmengie

The cleanest look is what OliviaMarsh suggested so that blank rows have a null string (which looks blank) instead of a 0, you will not have error triangles when you are entering values into B and C, and you can use SUM(D) to sum them up (assuming SUM is in a footer row). But here are two other ideas:


1) No change to your formulas in D. The formula for the sum is =SUMIF(D,"<>"&0,D)


2) The formula in each row of D is =DURATION(0,STRIPDURATION(C−B)) . This turns C-B into a decimal number of days then turns it back into a duration. All the results will be durations with units of days hours and minutes so you'll probably want to format these cells to be hours and minutes only. The sum will be a simple =SUM(D).

Aug 21, 2024 1:15 PM in response to shmengie

The problem is that you have two different data types here - dates (or durations) and numbers. SUM() cannot work like that.


The trick here is to filter out the valid vs. invalid cells to sum.


My first thought was a SUMIF() function, but I couldn't get it to work without some extra hoops.


The way I managed it was by adding an additional column (E) (which you can hide if you don't want to see it), that simply contains:


E2: =ISDATE(B2)


This sets up a TRUE/FALSE check to see if there are dates in the B column for the row. If there is, it's TRUE.


This can then be incorporated into the summary field at the bottom:


=SUMIF(E,"=TRUE",D)


This checks the values in column E to see if they are TRUE. For each match, it adds the value in column D.




As I said, you can hide column E so you don't see all the TRUE/FALSE values.

Aug 22, 2024 1:46 PM in response to shmengie

Absolutely!


It's both the bane and the power of Numbers - multiple ways to achieve the result.


While often more complex up-front, I often take the hidden column path since it simplifies the formulas in the main table (e.g. a simple "=B4-B3") and some of the complex logic functions are simply hard to read, especially once you start to add multiple conditionals ( e.g. "=IF(AND(OR(B4>0,C4>0),NOT(A4="")),D4,0)").


Maybe if I spent more time in spreadsheets, crafting them daily vs. every now and then, the syntax would be more second nature (like many programming languages).

I also think there's a lot that could be done to simplify entering complex equations, even while maintaining Excel compatibility (which is where much of the syntax mess comes from, IMHO). The above formula is (to me, at least), much easier to read as:


IF ( B4> 0 OR C4> 0) AND (A4 ≠ "") THEN
  RETURN D4
ELSE
 RETURN ""
END IF

Autosum, but with some blank formulas. I'll explain...

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.