SUMIF On Column Where Single Column is Primary Key for Numerous Criteria?

PacSum

New Member
Joined
Jan 8, 2017
Messages
30
I couldn't come up with a clear title. Here's the question with a proper example.

Two Tables of Data:

TABLE A
[TABLE="width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]GP[/TD]
[TD]M[/TD]
[TD]P[/TD]
[TD]A[/TD]
[TD]R[/TD]
[/TR]
[TR]
[TD]James[/TD]
[TD]80[/TD]
[TD]3040[/TD]
[TD]2320[/TD]
[TD]880[/TD]
[TD]480[/TD]
[/TR]
[TR]
[TD]Steph[/TD]
[TD]72[/TD]
[TD]2448[/TD]
[TD]1800[/TD]
[TD]576[/TD]
[TD]288[/TD]
[/TR]
[TR]
[TD]Kevin[/TD]
[TD]73[/TD]
[TD]2555[/TD]
[TD]1971[/TD]
[TD]511[/TD]
[TD]511[/TD]
[/TR]
[TR]
[TD]Chris[/TD]
[TD]78[/TD]
[TD]2730[/TD]
[TD]1404[/TD]
[TD]780[/TD]
[TD]234[/TD]
[/TR]
[TR]
[TD]Patrick[/TD]
[TD]80[/TD]
[TD]3200[/TD]
[TD]1760[/TD]
[TD]160[/TD]
[TD]960[/TD]
[/TR]
</tbody>[/TABLE]

TABLE B
[TABLE="width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Team[/TD]
[TD]Position[/TD]
[/TR]
[TR]
[TD]James[/TD]
[TD]Houston[/TD]
[TD]Forward[/TD]
[/TR]
[TR]
[TD]Steph[/TD]
[TD]Warriors[/TD]
[TD]Guard[/TD]
[/TR]
[TR]
[TD]Kevin[/TD]
[TD]Warriors[/TD]
[TD]Forward[/TD]
[/TR]
[TR]
[TD]Chris[/TD]
[TD]Houston[/TD]
[TD]Guard
[/TD]
[/TR]
[TR]
[TD]Patrick[/TD]
[TD]New York[/TD]
[TD]Center[/TD]
[/TR]
</tbody>[/TABLE]

I want to do SUMIF statements on Table A.

I want the SUM of all P for Names on Team Houston. We can look at Table B and see that this would be James and Chris. So this should be 2320+1404.

The simple way would be to aggregate all data into a single table, but that would get quite messy since there is a lot more data than shown in the example.

Any ideas? Thanks in advance!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try


[Table="class: grid"][tr][td="bgcolor: #DCE6F1"][/td][td="bgcolor: #DCE6F1"]
A
[/td][td="bgcolor: #DCE6F1"]
B
[/td][td="bgcolor: #DCE6F1"]
C
[/td][td="bgcolor: #DCE6F1"]
D
[/td][td="bgcolor: #DCE6F1"]
E
[/td][td="bgcolor: #DCE6F1"]
F
[/td][td="bgcolor: #DCE6F1"]
G
[/td][td="bgcolor: #DCE6F1"]
H
[/td][td="bgcolor: #DCE6F1"]
I
[/td][td="bgcolor: #DCE6F1"]
J
[/td][/tr]
[tr][td="bgcolor: #DCE6F1"]
1
[/td][td]
Name​
[/td][td]
GP​
[/td][td]
M​
[/td][td]
P​
[/td][td]
A​
[/td][td]
R​
[/td][td][/td][td]
Crit1​
[/td][td]
Crit2​
[/td][td]
Result​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
2
[/td][td]
James​
[/td][td]
80​
[/td][td]
3040​
[/td][td]
2320​
[/td][td]
880​
[/td][td]
480​
[/td][td][/td][td]
P​
[/td][td]
Houston​
[/td][td]
3724​
[/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
3
[/td][td]
Steph​
[/td][td]
72​
[/td][td]
2448​
[/td][td]
1800​
[/td][td]
576​
[/td][td]
288​
[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
4
[/td][td]
Kevin​
[/td][td]
73​
[/td][td]
2555​
[/td][td]
1971​
[/td][td]
511​
[/td][td]
511​
[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
5
[/td][td]
Chris​
[/td][td]
78​
[/td][td]
2730​
[/td][td]
1404​
[/td][td]
780​
[/td][td]
234​
[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
6
[/td][td]
Patrick​
[/td][td]
80​
[/td][td]
3200​
[/td][td]
1760​
[/td][td]
160​
[/td][td]
960​
[/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
7
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
8
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
9
[/td][td]
Name​
[/td][td]
Team​
[/td][td]
Position​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
10
[/td][td]
James​
[/td][td]
Houston​
[/td][td]
Forward​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
11
[/td][td]
Steph​
[/td][td]
Warriors​
[/td][td]
Guard​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
12
[/td][td]
Kevin​
[/td][td]
Warriors​
[/td][td]
Forward​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
13
[/td][td]
Chris​
[/td][td]
Houston​
[/td][td]
Guard​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
14
[/td][td]
Patrick​
[/td][td]
New York​
[/td][td]
Center​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr][td="bgcolor: #DCE6F1"]
15
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


Criteria in H2:I2

Array formula in J2
=SUM(SUMIF(A$2:A$6,IF(B$10:B$14=I2,A$10:A$14),INDEX(B$2:F$6,0,MATCH(H2,B$1:F$1,0))))
confirmed with Ctrl+Shift+Enter, not just Enter

M.
 
Upvote 0
Try


[TABLE="class: grid"]
<tbody>[TR]
[TD="bgcolor: #DCE6F1"][/TD]
[TD="bgcolor: #DCE6F1"]
A
[/TD]
[TD="bgcolor: #DCE6F1"]
B
[/TD]
[TD="bgcolor: #DCE6F1"]
C
[/TD]
[TD="bgcolor: #DCE6F1"]
D
[/TD]
[TD="bgcolor: #DCE6F1"]
E
[/TD]
[TD="bgcolor: #DCE6F1"]
F
[/TD]
[TD="bgcolor: #DCE6F1"]
G
[/TD]
[TD="bgcolor: #DCE6F1"]
H
[/TD]
[TD="bgcolor: #DCE6F1"]
I
[/TD]
[TD="bgcolor: #DCE6F1"]
J
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
1
[/TD]
[TD]
Name​
[/TD]
[TD]
GP​
[/TD]
[TD]
M​
[/TD]
[TD]
P​
[/TD]
[TD]
A​
[/TD]
[TD]
R​
[/TD]
[TD][/TD]
[TD]
Crit1​
[/TD]
[TD]
Crit2​
[/TD]
[TD]
Result​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
2
[/TD]
[TD]
James​
[/TD]
[TD]
80​
[/TD]
[TD]
3040​
[/TD]
[TD]
2320​
[/TD]
[TD]
880​
[/TD]
[TD]
480​
[/TD]
[TD][/TD]
[TD]
P​
[/TD]
[TD]
Houston​
[/TD]
[TD]
3724​
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
3
[/TD]
[TD]
Steph​
[/TD]
[TD]
72​
[/TD]
[TD]
2448​
[/TD]
[TD]
1800​
[/TD]
[TD]
576​
[/TD]
[TD]
288​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
4
[/TD]
[TD]
Kevin​
[/TD]
[TD]
73​
[/TD]
[TD]
2555​
[/TD]
[TD]
1971​
[/TD]
[TD]
511​
[/TD]
[TD]
511​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
5
[/TD]
[TD]
Chris​
[/TD]
[TD]
78​
[/TD]
[TD]
2730​
[/TD]
[TD]
1404​
[/TD]
[TD]
780​
[/TD]
[TD]
234​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
6
[/TD]
[TD]
Patrick​
[/TD]
[TD]
80​
[/TD]
[TD]
3200​
[/TD]
[TD]
1760​
[/TD]
[TD]
160​
[/TD]
[TD]
960​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
7
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
8
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
9
[/TD]
[TD]
Name​
[/TD]
[TD]
Team​
[/TD]
[TD]
Position​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
10
[/TD]
[TD]
James​
[/TD]
[TD]
Houston​
[/TD]
[TD]
Forward​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
11
[/TD]
[TD]
Steph​
[/TD]
[TD]
Warriors​
[/TD]
[TD]
Guard​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
12
[/TD]
[TD]
Kevin​
[/TD]
[TD]
Warriors​
[/TD]
[TD]
Forward​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
13
[/TD]
[TD]
Chris​
[/TD]
[TD]
Houston​
[/TD]
[TD]
Guard​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
14
[/TD]
[TD]
Patrick​
[/TD]
[TD]
New York​
[/TD]
[TD]
Center​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]
15
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Criteria in H2:I2

Array formula in J2
=SUM(SUMIF(A$2:A$6,IF(B$10:B$14=I2,A$10:A$14),INDEX(B$2:F$6,0,MATCH(H2,B$1:F$1,0))))
confirmed with Ctrl+Shift+Enter, not just Enter

M.

Absolutely perfect. Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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