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!!!
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,618
Office Version
  1. 2007
Platform
  1. Windows
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
)))))
 

dmitrevski

New Member
Joined
Feb 28, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
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!
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,618
Office Version
  1. 2007
Platform
  1. Windows
I'm glad to help you. Thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,126,986
Messages
5,621,995
Members
415,873
Latest member
fuulhouse

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
Top