SOLVED

New Contributor

# Add a difference between numbers with minus

Hi,

I want to create a formula that gives the number 2 if two cells are equal, but if the numbers are different - I want to get the difference between them, but in negative form (For example: If A1 is 6 and B1 is 4, I want to get -2). I want to clarify that a simple sum formula probably isn't good in that case because in some cases A would be the bigger number, and in other cases B would be the bigger, and I want it to always be negative.

I made the first step of the formula - =IF(A1=B1,2) - but don't know how to proceed from here.

Thanks in advance!

4 Replies
best response confirmed by Matan_Avishai (New Contributor)
Solution

# Re: Add a difference between numbers with minus

=IF(A1=B1, 2, -ABS(A1-B1))

# Re: Add a difference between numbers with minus

Thank you!
Is there a way to leave this cell blank as long as I don't fill the other two (right now it says 2 because the empty cells are equals..)?
It's not critical, but I'd like to do it if possible.

Thanks again!

# Re: Add a difference between numbers with minus

Yep.

=IF(OR(A1="", B1=""), "", IF(A1=B1, 2, -ABS(A1-B1)))

# Re: Add a difference between numbers with minus

You legend. Thank you so much!