# If and or statement not working

#### Andreak14

##### New Member
SO i am trying to add columns to establish events. In the one scenario I have four columns and one is basically a parent field and has four child fields. Two of the fields have to be added if the parent is greater than zero. The formula does not seem to be working.

=T2+AA2+AC2+AY2+IF(AND(U2=1,OR(X2=1,Y2=1)),1,0)

So the U2 is the parent field and If either the x2=1 or the y2=1 then add a one (1) if not zero (0). It can also be x2=1 and y2=1.

Cannot figure out why its not working any ideas would be great.

Andi

### Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi and welcome to the Board
This works for me
Code:
``=IF(AND(U2=1,OR(X2=1,Y2=1)),1,0)+SUM(T2+AA2+AC2+AY2)``

Try thus AA2 AC2 T2 + + + + SE AY2 (E (U2 = 1, X 2 = 1)) 1.0).

: D

It looks like it should work to me.
Can you give an example of T2, AA2, AC2, AY2, U2, X2 and Y2 with the desired result that doesn't act the way you want?

It looks like it should work to me.
Can you give an example of T2, AA2, AC2, AY2, U2, X2 and Y2 with the desired result that doesn't act the way you want?

Ok, thanks everyone, here is an example

T2=0, AA2=0, AC2=0, AY2=0, u2=1, x2=1, y2=0
I am getting a total of 0
I should get a total of 1 due to the if u2=1, x2=1 and sum in with the equation, correct?

Hope this helps.

Thank you everyone, sorry but just realized that the child fields came over from access formatted as Text. Once I converted to number the formulas worked. Sorry to waste your time.

The formula in the OP returns 1 for the data you gave.
Is it possible that some U1, X1 or Y1 are text instead of numbers? (e.g. the string "1" rather than the number 1)

Replies
1
Views
267
Replies
1
Views
1K
Replies
2
Views
765
Replies
0
Views
194
Replies
0
Views
378

1,203,326
Messages
6,054,747
Members
444,748
Latest member
knowak87

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