Forum Discussion
nested "IF" with "AND" and "IF" with "OR" function
Hi All,
can somebody please help with the following?
I am trying to do 3 conditions, using nested "IF" with "AND" functions and "IF" with "OR" functions. Let's assume cell c3=2 and cell c4=3. what I am trying to achieve is the following, if c3=2 and c4=3 than display 100, if c3<>2 or c4<>3 then display 50, if c3<>2 and c4<>3 then display 0.
I have tried the following formula which covers the first two conditions, but I cannot figure out how to get the third condition working. TIA
=IF(AND(C3=2,C4=3),"100",IF(OR(C3<>2,C4<>3),"50","0"))
=IF(AND(C3=2,C4=3),"100",IF(OR(C3<>2,C4<>3),"50",IF(AND(C3<>"2",C4<>"3"),"0")))
- Hi there
Try this:
=IF(AND(C3=2,C4=3),"100",IF(AND(C3<>2,C4<>3),"0","50"))
Hope that works? Let us know how you go.
Cheers
Damien
6 Replies
- SergeiBaklanDiamond Contributor
Alternatively that could be as
=TEXT(((C3=2)+(C4=3))*50,"0")
if the result shall be returned as text
- xmishaniagxCopper Contributor
Thank you, that worked. However, I do not really understand the logic. ;-) I guess I would need to look into how you did it.
- SergeiBaklanDiamond Contributor
That is based on the fact what TRUE is equal to 1 and FALSE is equal 0.
If both are TRUE you have 2*50
If one OR another is TRUE you have 1*50
If both are false you have 0*50
- Damien_RosarioSilver ContributorHi there
Try this:
=IF(AND(C3=2,C4=3),"100",IF(AND(C3<>2,C4<>3),"0","50"))
Hope that works? Let us know how you go.
Cheers
Damien- xmishaniagxCopper Contributor
Thank you very much, Damien.
- Damien_RosarioSilver ContributorNo worries friend. You did all the heavy lifting, all I did was adjust your formula to give you the desired result. Great team work!
All the best.
Cheers
Damien