SUM the table using the Criteria and Position

austinandreikurt

Board Regular
Joined
Aug 25, 2020
Messages
91
Office Version
  1. 2016
Platform
  1. Windows
Hi! I need help in trying to sum the values on a table range say it is from A1:B5 based on a criteria. I have a table of criteria in Column P to R like below:

PersonColumnRow
Apple
5​
5​
Orange
1​
1​
Apple
1​
1​

What I need is to get the sum/average values from A1:B5 of all "Apple" based on the column and row specified in Column P to R and it should ignore the blank instances. Say there might be a row for Apple in Column P but no values in Columns Q and R.
 
Sure:
MrExcel_Sum_the_table_using_the_criteria_and_position.xlsx
V
1Average w/o empty
213
31
413
514
614
713
Tabelle1
Cell Formulas
RangeFormula
V2:V7V2=SUMPRODUCT(--($P2=$P$2:$P$7),$Q$2:$Q$7,$R$2:$R$7)/SUMPRODUCT(--($P2=$P$2:$P$7),--($S$2:$S$7>0))
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi Sulprobil, from the formula, how will it get the data from A1 to B5 as I cannot see it in the formula? Also, it still give reference to Column S? But I only have the data in A1:B5 and Column P to R in other sheets
 
Upvote 0
Sorry, I think I got it now, but just with helper columns:
MrExcel_Sum_the_table_using_the_criteria_and_position.xlsx
PQRSTU
1PersonColumnRowSum 1Sum AllAverage w/o empty
2Apple55252613
3Orange11111
4Apple1112613
5Pea34183517,5
6Pea24173517,5
7Apple02613
Tabelle1
Cell Formulas
RangeFormula
S2:S7S2=IF(COUNT(Q2:R2)=2,INDIRECT(“R”&R2&”C”&Q2,FALSE),0)
T2:T7T2=SUMIF($P$2:$P$7,$P2,$S$2:$S$7)
U2:U7U2=T2/SUMPRODUCT(--($P2=$P$2:$P$7),--($S$2:$S$7>0))


Honestly, I do not like INDIRECT. If you could describe the whole process of yours, we might we able to help you in a better way.
 
Upvote 0
Without INDIRECT:
MrExcel_Sum_the_table_using_the_criteria_and_position.xlsx
ABCDEFGHIJKLMNOPQRSTU
112345PersonColumnRowSum 1Sum AllAverage w/o empty
2678910Apple55252613
31112131415Orange11111
41617181920Apple1112613
52122232425Pea34183517,5
6Pea24173517,5
7Apple02613
Tabelle1
Cell Formulas
RangeFormula
S2:S7S2=IF(COUNT(Q2:R2)=2,INDEX($A$1:$E$5,$R2,$Q2),0)
T2:T7T2=SUMIF($P$2:$P$7,$P2,$S$2:$S$7)
U2:U7U2=T2/SUMPRODUCT(--($P2=$P$2:$P$7),--($S$2:$S$7>0))
 
Upvote 0
Thanks Sulprobil. This is enough solution for me. I will just hide the helper columns using Column Grouping. Thanks again!
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,072
Latest member
DW Draft

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