Combining multiple nested IFs with an OR condition

dmitrevski

New Member
Joined
Feb 28, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I need help with joining two sets of multiple nested IF formulas. I believe I need to use the OR condition but can't get this to work.
I'm essentially trying to say : IF D12 > D21 , do this... OR IF D12 < D21 do this... I can evaluate the each nested IF before and after the OR successfully.
It's when I try to combine the two pieces that I run into trouble.
Excel is not my first language. I'm a SQL developer, so getting the syntax correctly is proving difficult for me.

These are my two sets of nested IFs that work on their own. How do I add the OR condition in, to create one large formula?
=IF(D12>D21,0,
IF(AND(AND(D15>0,D12<=D21),D12>=D22),(D22-D12)*-0.5,
IF(AND(AND(D15<0,D12<=D21),D12>=D22),(D22-D12)*0.5,
IF(AND(AND(D15>0,D12<=D22),D12>=D23),(D22-D12)*-0.5,
IF(AND(AND(D15<0,D12<=D22),D12>=D23),(D22-D12)*0.5
)))))


=IF(D12<D21,0,
IF(AND(AND(D15>0,D12<=D21),D12>=D22),(D12-D22)*-0.5,
IF(AND(AND(D15<0,D12<=D21),D12>=D22),(D12-D22)*0.5,
IF(AND(AND(D15>0,D12<=D22),D12>=D23),(D12-D22)*-0.5,
IF(AND(AND(D15<0,D12<=D22),D12>=D23),(D12-D22)*0.5
)))))

Thank you!!!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
How about:

=IF(D12>D21,
IF(AND(AND(D15>0,D12<=D21),D12>=D22),(D12-D22)*-0.5,
IF(AND(AND(D15<0,D12<=D21),D12>=D22),(D12-D22)*0.5,
IF(AND(AND(D15>0,D12<=D22),D12>=D23),(D12-D22)*-0.5,
IF(AND(AND(D15<0,D12<=D22),D12>=D23),(D12-D22)*0.5)))),
IF(AND(AND(D15>0,D12<=D21),D12>=D22),(D22-D12)*-0.5,
IF(AND(AND(D15<0,D12<=D21),D12>=D22),(D22-D12)*0.5,
IF(AND(AND(D15>0,D12<=D22),D12>=D23),(D22-D12)*-0.5,
IF(AND(AND(D15<0,D12<=D22),D12>=D23),(D22-D12)*0.5
)))))
 
Upvote 0
Ah, thank you Dante! I see what you did there, with replacing the 'zero' argument with the one of the OR conditions. I'm going to continue testing scenarios, but it looks to be working for me. Thank you again!
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top