Looking for a simplified SUMPRODUCT solution

dwgnome

Active Member
Joined
Dec 18, 2005
Messages
441
Hi,

I have one column with code letters such as T, S, P, O, the other column values. I want to sum the values when a corresponding matching letter is present.

Code:
=SUMPRODUCT(--(CAT="T"),DV12:DV74)

Works, but

Code:
=SUMPRODUCT(--(CAT="T"),--(CAT="O"),DV12:DV74)
does not.

I even tried:

Code:
=SUMPRODUCT(--(ISNUMBER(SEARCH(CAT,"T"))),--(ISNUMBER(SEARCH(CAT,"O"))),DV12:DV74)

what I really want to do is to not have to add two similar expressions but do something like this:

Code:
=SUMPRODUCT(--(CAT={"T","O"}),DV12:DV74)

Thanks.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
=SUMPRODUCT(--(CAT="T"),--(CAT="O"),DV12:DV74) does not work because those cells in CAT that are equal to T are not equal to O. Consequently the result will always be zero. Try (untested):

=SUMPRODUCT(CAT="T")+(CAT="O"),DV12:DV74)
 
Upvote 0
Thank you sheetspread and west man. I guess trying to use an array within SUMPRODUCT doesn't work. However, I see that the following formula does what I envision:

Code:
=[B][COLOR=#0000ff]SUM(IF(E12:E74={"O","S"},DY12:DY74))[/COLOR][/B]

However, it is a array formula (CSE). I was hoping I can do the {"O","S"} bit within a non-array like SUMPRODUCT.
 
Upvote 0
Thank you sheetspread and west man. I guess trying to use an array within SUMPRODUCT doesn't work. However, I see that the following formula does what I envision:

Code:
=[B][COLOR=#0000ff]SUM(IF(E12:E74={"O","S"},DY12:DY74))[/COLOR][/B]

However, it is a array formula (CSE). I was hoping I can do the {"O","S"} bit within a non-array like SUMPRODUCT.

1) Just enter:

=SUMPRODUCT(--ISNUMBER(MATCH(E12:E74,{"O","S"},0)),DY12:DY74)

2) Just enter:

=SUM(SUMIF(E12:E74,{"O","S"},DY12:DY74)

3) CSE...

=SUM(IF(ISNUMBER(MATCH(E12:E74,{"O","S"},0)),DY12:DY74))

Note 1. If the array constant is admissible (no need for a range-based list), option (2) is the best thing to do.

Note 2. While a SumProduct formula does not require CSE, it is just as much an array-processing formula.
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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