Apple Numbers - Formula needed that will only calculate if a specific cell value is greater than 0

I have a basic sum formula for 2 cells.


Basically SUM A1 + B1


I need the SUM to only calculate if B1 is greater than 0


Can anyone assist with this?

Posted on Nov 28, 2022 9:33 AM

Reply
Question marked as Top-ranking reply

Posted on Nov 28, 2022 10:15 AM

Hi Nick,


Here are two:


IF(B1>0,A1+B1,"")


IF(B1>0,SUM(A1,B1),"")


In both, you'll need to replace "" with what result you want when B1 is not greater than zero. As written, the result will be the empty string, a text value with 0 length, and the cell containing the formula will appear empty.


Regards,

Barry


4 replies
Question marked as Top-ranking reply

Nov 28, 2022 10:15 AM in response to NickP937

Hi Nick,


Here are two:


IF(B1>0,A1+B1,"")


IF(B1>0,SUM(A1,B1),"")


In both, you'll need to replace "" with what result you want when B1 is not greater than zero. As written, the result will be the empty string, a text value with 0 length, and the cell containing the formula will appear empty.


Regards,

Barry


Nov 28, 2022 2:01 PM in response to NickP937

I see it is already answered but here is another formula assuming you want A1+B1 if B>0 and want A1 if B<=0

=MAX(A1,A1+B1)

or

=MAX(A1,SUM(A1,B1))


The first will choke if it encounters letters/words instead of numbers and will throw an error. The second will ignore all text (including numbers that are in cells formatted as text) or will consider it to be 0.


Nov 28, 2022 12:15 PM in response to NickP937

I propose this formula that determines if cell B1 contains a numeric value and it is greater than zero. When true, it does the sum of A1, B1, and when false, enters the string "B1 is alpha".


Testing B1 > 0 will return true even when B1 contains "A", and that leads to issues. So we must ensure it is numeric.



IFERROR(IF(REGEX.EXTRACT(B1,"(\d+)",1) > 0,SUM(A1,B1),""),"B1 is alpha")

This basically captures and returns any numeric (\d+) value in cell B1 and compares that to zero. If B1 contains non-numeric data, then it is an extract error, and the error condition text string is inserted into the cell with this formula.


This also handles negative and decimal numbers in cell B1.


Tested: Numbers v12.2, macOS Ventura 13.0.1.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Apple Numbers - Formula needed that will only calculate if a specific cell value is greater than 0

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