# Combining multiple nested IFs with an OR condition

#### dmitrevski

##### New Member
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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

#### DanteAmor

##### Well-known Member

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

Replies
2
Views
140
Replies
8
Views
106
Replies
2
Views
51
Replies
9
Views
164
Replies
4
Views
745

1,127,619
Messages
5,625,891
Members
416,141
Latest member
Bartek9q

### 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.

### Which adblocker are you using?

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

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