SumProduct Different Sum Range Based on Criteria

neb255

Board Regular
Joined
Sep 14, 2011
Messages
64
Hi,

Im working in Excel 2016. I am looking to find out if it is possible to designate different sum ranges for one specific criteria in a sumproduct formula while the rest of the conditions apply to both.

Example:

ABCDE
1ColorMonthForSaleAM1Am2
2Black1Y50100
3Blue1Y10050
4Black1N75100
5Blue1N2575
6Black1N10025
7Blue1Y75100
8Black2Y50150
9Blue2N100100

<tbody>
</tbody>

In the above table we want the sum of all Black or Blue where Month = 1 and ForSale = Y. The only variable is that for Black we want to return AM1 while Blue should return AM2.

So at its most basic this would be
Code:
SUMPRODUCT(($A$2:$A$9="Black")*($B$2:$B$9=1)*($C$2:$C$9="Y")*($D$2:$D$9))+SUMPRODUCT(($A$2:$A$9="Blue")*($B$2:$B$9=1)*($C$2:$C$9="Y")*($E$2:$E$9))

The idea here would be to avoid writing the whole sum product twice and then adding them since this would require a second iteration.

Thanks in advance for any help

Cheers!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Try this

=SUMPRODUCT((A2:A9={"Black","Blue"})*(B2:B9=1)*(C2:C9="Y")*(D2:E9))
 
Upvote 0
Try this

=SUMPRODUCT((A2:A9={"Black","Blue"})*(B2:B9=1)*(C2:C9="Y")*(D2:E9))

Thanks that worked for my above question, I realize however as I'm re-reading my post that I asked the question incorrectly. It should have been Black is from AM1 and any other color (so <> Black) is from AM2.
 
Upvote 0
I realize as I'm re-reading my post that I asked the question incorrectly. It should have been Black is from AM1 and any other color (so <> Black) is from AM2. so the original code would have been
Code:
[COLOR=#333333]SUMPRODUCT(($A$2:$A$9="Black")*($B$2:$B$9=1)*($C$2:$C$9="Y")*($D$2:$D$9))+SUMPRODUCT(($A$2:$A$9<>"Black")*($B$2:$B$9=1)*($C$2:$C$9="Y")*($E$2:$E$9))[/COLOR]

I found a possible answer which was
Code:
[COLOR=#333333]SUMPRODUCT(($B$2:$B$9=1)*($C$2:$C$9="Y")*(([/COLOR][COLOR=#333333]($A$2:$A$9="Black")*[/COLOR][COLOR=#333333]($D$2:$D$9))+(($A$2:$A$9<>"Black")*($E$2:$E$9))))[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,215,678
Messages
6,126,176
Members
449,296
Latest member
tinneytwin

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