Sum with Multiple IF AND OR Conditions

Argh

New Member
Joined
Apr 4, 2011
Messages
5
Can't seem to find the correct way to put this in a formula, any help would be very much appreciated. It is counting each row if it meets the conditions.

Basically:

SUM (IF(A AND B) AND IF((C) AND/OR (D) AND/OR (E)))

Complexly:

SUM (IF(A1:A2000="value" AND B1:B2000="value") AND IF(C1:C2000="value" AND/OR D1:D2000="value" AND/OR D1:D2000="value"))
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Can't seem to find the correct way to put this in a formula, any help would be very much appreciated. It is counting each row if it meets the conditions.

Basically:

SUM (IF(A AND B) AND IF((C) AND/OR (D) AND/OR (E)))

Complexly:

SUM (IF(A1:A2000="value" AND B1:B2000="value") AND IF(C1:C2000="value" AND/OR D1:D2000="value" AND/OR D1:D2000="value"))
You have AND/OR D1:D2000="value" repeated.

Well, that "pseudo formula" still isn't clear (to me).

Is this a good description:

if A = this and If B = this and if C or D = this

What version of Excel are you using?
 
Upvote 0
Based on the Sumproduct you just posted, could this be what you need...

=SUMPRODUCT(--(A1:A2000="value"),--(B1:B2000="value"),--(C1:C2000="value"),--(D1:D2000="value"))
 
Upvote 0
As always, after working for hours and then posting on forums, I finally get it right. Here is the code for anyone else who hits a similar wall:

SUMPRODUCT(A1:A2000="value")*('B1:B2000="value")*(OR(C1:C2000="value",D1:D2000="value",E1:E2000="value")))"
If that returns a correct result it's just "dumb luck".

The OR function isn't doing what you think it's doing.

In C, D and E is "value" the same? Like this:

(C1:C2000="X",D1:D2000="X",E1:E2000="X")
 
Upvote 0
Sorry I should justify my formula:

SUM (IF(A1:A2000="a" AND B1:B2000="b") AND IF(C1:C2000="c" AND/OR D1:D2000="d" AND/OR E1:E2000="e"))

The value that the lookups are equalling are not important, just the fact that there is a lookup on multiple columns such as this (A&B)&(C&/D&/E)

Two conditions:

A and B have to contain the values assigned to them
One or more of C, D or E have to contain the values assigned to them

If so, counter ++
Else, nextrow

Cases:
Row 1: A contains its required value, B contains its required value BUT C, D or E do not, counter stays at 0.
Row 2: A contains its required value, B contains its required value, C contains its required value, BUT D or E do not, counter++
Row 3: A contains its required value, B contains its required value, D contains its required value, BUT C or E do not, counter++
Row 4: A contains its required value, B contains its required value, C contains its required value, D contains it's required value BUT E does not, counter++
Row 5: A contains its required value, B does not, nextrow
 
Last edited:
Upvote 0
Sorry I should justify my formula:

SUM (IF(A1:A2000="a" AND B1:B2000="b") AND IF(C1:C2000="c" AND/OR D1:D2000="d" AND/OR E1:E2000="e"))

The value that the lookups are equalling are not important, just the fact that there is a lookup on multiple columns such as this (A&B)&(C&/D&/E)

Two conditions:

A and B have to contain the values assigned to them
One or more of C, D or E have to contain the values assigned to them

If so, counter ++
Else, nextrow

Cases:
Row 1: A contains its required value, B contains its required value BUT C, D or E do not, counter stays at 0.
Row 2: A contains its required value, B contains its required value, C contains its required value, BUT D or E do not, counter++
Row 3: A contains its required value, B contains its required value, D contains its required value, BUT C or E do not, counter++
Row 4: A contains its required value, B contains its required value, C contains its required value, D contains it's required value BUT E does not, counter++
Row 5: A contains its required value, B does not, nextrow
Let's assume this is your data:

Book1
ABCDE
1AB
2ABCE
3BCD
4ABDE
5ABCDE
6ABCDE
7ABC
8ABCDE
9ABE
10ACDE
Sheet1


This formula:

=SUMPRODUCT(--(A1:A10="A"),--(B1:B10="B"),SIGN((C1:C10="C")+(D1:D10="D")+(E1:E10="E")))

Returns a count of 7.
 
Upvote 0

Forum statistics

Threads
1,224,565
Messages
6,179,549
Members
452,927
Latest member
rows and columns

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