Mariana da Costa
Mariana da Costa

Reputation: 173

Join two =if - excel

I have this two if functions:

=IF(C5<15;15-C5;0)
=IF(C5>15;C5-15;0)

Is it possible to join them into the same cell?

Thanks.

Upvotes: 0

Views: 86

Answers (2)

Mister 832
Mister 832

Reputation: 1221

This should do

If(C5<15;15-C5;If(C5>15;C5-15;0))

Upvotes: 1

JNevill
JNevill

Reputation: 50019

You could nest the if statements:

If(C5<15;15-C5;If(C5>15;C5-15;0))

Since both have 0 as the "Else" parameter (when the condition is false) you could add them together:

 =IF(C5<15;15-C5;0) + IF(C5>15;C5-15;0)

Since it's just arithmetic you could get rid of the ifs:

 =((C5<15)*(15-C5)) + ((C5>15)*(C5-15))

Also... this whole mess could be simplified down to just:

 =ABS(C5-15)

Upvotes: 5

Related Questions