SUMPRODUCT or INDEX/MATCH When Summing for Certain Criteria

alexb523

Board Regular
Joined
Dec 12, 2013
Messages
115
Hello Board Users,

I am trying to SUM everything that is the same letter and under a certain column count. The formula i am using seems to work when the "columns" are in asending order, but I would like to modify it to only Sum the columns below a certain count.

Here is the Formula i am currently using:

Code:
=SUMPRODUCT($B$2:$G$9*($A$2:$A$9=$A12)*($B$1:$G$1<=$B12))

The Table below starts in "A1". The SUM field is what I would like the out come to be.
For example, letter "a" should SUM every row from the input table that is "a" and less than the 3rd column of the table. Right now, it SUMS everything that is "a" row that is less than the Num.

Is this possilbe? Or will i have to adjust my table?

Thanks in advance. Really appreciate anybody's help.

alexb523
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Sorry! Below is the table!

101112123
a123456
a369121518
b91827364554
b275481108135162
c81162243324405486
c24348672997212151458
d72914582187291636454374
a21874374656187481093513122
LetterNumShould SUMNOW
a121314646011
b11108648
c248602916
d129162916

<colgroup><col><col><col><col><col><col span="2"></colgroup><tbody>
</tbody>
 
Upvote 0
Try

=SUMPRODUCT($B$2:INDEX($B$9:$G$9,MATCH(B12,$B$1:$G$1,0))*($A$2:$A$9=$A12))
 
Upvote 0
Thanks Jonmo1! That is slick.

Let me try to understand this:

SUMPRODUCT($B$2:INDEX($B$9:$G$9 --> that gets you your "MAX" range you would SUM(B2:G9)

Then the match tells you how many columns should be in that range (B2:NumColumns in Row 9) to look up based on the "Num" Column and what row numbers to SUM from the letter.

Correct?

Why is it not a Array Formula? I feel like that is usually the case with "MATCH(X*Y)" criteria.

Thanks Again!
 
Upvote 0
That's about right.

The match isn't actually used as part of the X*Y calculation.
It's only purpose is to determine the ending column of the first range.

=SUMPRODUCT($B$2:INDEX($B$9:$G$9,MATCH(B12,$B$1:$G$1,0))*($A$2:$A$9=$A12))

Say the value of B12 was found in E1 for example
MATCH(B12,$B$1:$G$1,0) = 4

=SUMPRODUCT($B$2:INDEX($B$9:$G$9,4)*($A$2:$A$9=$A12))

INDEX($B$9:$G$9,4) = E9 (E is the 4th column in B9:G9)

=SUMPRODUCT($B$2:$E$9*($A$2:$A$9=$A12))

From there, it works the same as your original formula (but now removed the < B12 criteria).
 
Last edited:
Upvote 0
Hello Junmo,

I use this function all time now. It is very useful in my industry/position in finding the LT usage.

I am wondering, how will this be effected but a Table? will indexing the last row change if the size/length of the table changes?

Please see my table question here.
 
Upvote 0

Forum statistics

Threads
1,215,254
Messages
6,123,893
Members
449,132
Latest member
Rosie14

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