Why does this Sumifs expression get an error?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,553
Office Version
  1. 365
Platform
  1. Windows
I need to calculate the average ratio of a set of numbers. This minisheet is a simple example.

In P11, I want to calculate the average ratio of the values in L/K for each value in J. The expression in O11 works, but the one in P11 does not. Can anyone tell me why? And what do I need to do to make it work. The values in J11:L16 are sorted on J, but I need the expression to work no matter how they are sorted.

Average Ratings.xlsx
JKLMNOP
11a24a2=sumifs(L11:L16/K11:K16,J11:J16,N11)
12a36b3
13a48
14b26
15b39
16b412
Test
Cell Formulas
RangeFormula
O11O11=SUM(L11:L13/K11:K13)/3
O12O12=SUM(L14:L16/K14:K16)/3


Thanks
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Does this work for you?
clean.xlsm
JKLMNOP
11a24a22
12a36b33
13a48
14b26
15b39
16b412
Sheet2
Cell Formulas
RangeFormula
O11O11=SUM(L11:L13/K11:K13)/3
P11:P12P11=SUMIF(J11:J16,N11,L11:L16)/SUMIF(J11:J16,N11,K11:K16)
O12O12=SUM(L14:L16/K14:K16)/3
 
Upvote 0
Does this work for you?
That only works if the ratios are all the same. I made them that way in the example above so I could reasily calculate it manually.

It does not work in this case. I added columns Q & R to help illustrate. Q is the ratios, which in the example above were all 2 for "a" and 3 for "b". R takes the average of the corresponding values (ratios) in M. I'd like a formula that does that without the intermediate values in Q.

Average Ratings.xlsx
JKLMNOPQR
11a26a2.25002.11113.0002.2500
12a36b2.88893.00002.0002.8889
13a471.750
14b252.500
15b382.667
16b4143.500
Test
Cell Formulas
RangeFormula
O11O11=SUM(L11:L13/K11:K13)/3
P11:P12P11=SUMIF(J11:J16,N11,L11:L16)/SUMIF(J11:J16,N11,K11:K16)
O12O12=SUM(L14:L16/K14:K16)/3
R11R11=SUMIFS(Q11:Q16,J11:J16,N11)/COUNTIFS(J11:J16,N11)
R12R12=SUMIFS(Q11:Q16,J11:J16,N12)/COUNTIFS(J11:J16,N12)
Q11:Q16Q11=L11/K11


Is that clearer?
 
Upvote 0
Typically an average of an average is mathematically invalid. This will give you the same result as above but it is longer so might not be worth it.
Excel Formula:
=LET(fltr,FILTER((L11:L16/K11:K16),J11:J16=N11),SUM(fltr)/COUNT(fltr))
 
Upvote 0
Typically an average of an average is mathematically invalid.
I don't think this is an average of an average. 🤔🤨🤔

This is what I am trying to do. I have a table of the amount of baking time it took to cook three different types of potatoes at three different oven temperatures. I wanted to see if I could calculate an average bake time at each oven temperature. To do that, I chose an average potato weight of 350g. Here are the tables.

The first one is the raw data. I've sorted it by Temp and then by Weight to make it easier to read.

The second one calculates the average ratings for each type of potato. That is working.

The last one is trying to calculate the average cook times for each of the three temperatures. To make it work, I had to add column J to the raw data table.

My question is how I can calculate the values in column Q without the values in column J?

Average Ratings.xlsx
DEFGHIJKLMNOPQ
4DateItemRatingWeightTempBake TimeTime /350gItemRatingCountTempTime /350g
59/21/22Yam92296g300°2.753.25Yam93.205300°3.27
69/18/22Russet75312g300°2.963.32Sweet86.005350°2.71
710/06/22Sweet85343g300°3.243.31Russet75.004400°2.19
810/14/22Russet70396g300°3.603.18
99/22/22Russet80325g350°2.582.78
109/25/22Yam90347g350°2.712.73
119/28/22Sweet85378g350°2.882.67
1210/03/22Yam95413g350°3.282.78
1310/09/22Sweet85423g350°3.152.61
149/30/22Yam94285g400°1.832.25
159/23/22Russet75293g400°1.872.23
1610/12/22Sweet85338g400°2.102.17
179/29/22Sweet90389g400°2.332.10
1810/08/22Yam95418g400°2.612.19
19Averages85.4354g
Multiple Properties
Cell Formulas
RangeFormula
M5:M7M5=IF([@Count]>0,SUMIFS(TblRtgs3[Rating],TblRtgs3[Item],[@Item])/[@Count],"--")
N5:N7N5=COUNTIFS(TblRtgs3[Item],[@Item])
Q5:Q7Q5=AVERAGEIFS(TblRtgs3[Time /350g],TblRtgs3[Temp],[@Temp])
J5:J18J5=[@[Bake Time]]/[@Weight]*350
F19F19=SUBTOTAL(101,[Rating])
G19G19=SUBTOTAL(101,[Weight])
 
Upvote 0
This will replicate your results without using Column J
Excel Formula:
=LET(fltr,FILTER((TblRtgs3[Bake
Time]/TblRtgs3[Weight]),TblRtgs3[Temp]=[@Temp]),SUM(fltr)/COUNT(fltr)*350)
 
Upvote 0
Solution
This will replicate your results without using Column J
Excel Formula:
=LET(fltr,FILTER((TblRtgs3[Bake
Time]/TblRtgs3[Weight]),TblRtgs3[Temp]=[@Temp]),SUM(fltr)/COUNT(fltr)*350)
That is incredible. I will have to study that one. 🤔🤨😯 I could never have come up with that myself. Thank you very much. 👍👍👏👏🥰

Here it is in action:

Average Ratings.xlsx
DEFGHIJKLMNOPQR
4DateItemRatingWeightTempBake TimeTime /350gItemRatingCountTempTime /350gWith Col J
59/21/22Yam92296g300°2.753.25Yam93.205300°3.273.27
69/18/22Russet75312g300°2.963.32Sweet86.005350°2.712.71
710/06/22Sweet85343g300°3.243.31Russet75.004400°2.192.19
810/14/22Russet70396g300°3.603.18
99/22/22Russet80325g350°2.582.78
109/25/22Yam90347g350°2.712.73
119/28/22Sweet85378g350°2.882.67
1210/03/22Yam95413g350°3.282.78
1310/09/22Sweet85423g350°3.152.61
149/30/22Yam94285g400°1.832.25
159/23/22Russet75293g400°1.872.23
1610/12/22Sweet85338g400°2.102.17
179/29/22Sweet90389g400°2.332.10
1810/08/22Yam95418g400°2.612.19
19Averages85.4354g
Multiple Properties
Cell Formulas
RangeFormula
M5:M7M5=IF([@Count]>0,SUMIFS(TblRtgs3[Rating],TblRtgs3[Item],[@Item])/[@Count],"--")
N5:N7N5=COUNTIFS(TblRtgs3[Item],[@Item])
Q5:Q7Q5=LET(fltr,FILTER((TblRtgs3[Bake Time]/TblRtgs3[Weight]),TblRtgs3[Temp]=[@Temp]),SUM(fltr)/COUNT(fltr)*350)
R5:R7R5=AVERAGEIFS(TblRtgs3[Time /350g],TblRtgs3[Temp],[@Temp])
J5:J18J5=[@[Bake Time]]/[@Weight]*350
F19F19=SUBTOTAL(101,[Rating])
G19G19=SUBTOTAL(101,[Weight])
 
Upvote 0
No problem. Let (groan) me know if you need me to talk you through it.
The "Let" statement just allows you to use variable names like you do in VBA. So in this case the Filter function is used twice in the final calculation but it is only calculated once and assigned to the variable fltr.
 
Upvote 0
No problem. Let (groan) me know if you need me to talk you through it.
The "Let" statement just allows you to use variable names like you do in VBA. So in this case the Filter function is used twice in the final calculation but it is only calculated once and assigned to the variable fltr.
Interesting. That looks like it could be quite handy. I'll add that to my (way too long) Excel To Do list.
 
Upvote 0
No problem. Let (groan) me know if you need me to talk you through it.

Perhaps you can explain why the Sum function will accept an expression as an argument (Q11:Q12), but neither SumIf nor SumIfs will (P11:P12 & R11:R12), which I have commented out because they get an error.

Average Ratings.xlsx
JKLMNOPQR
11a47a2.2500=sumifs(L11:L16/K11:K16,J11:J16,N11)2.2500=sumif(J11:J16,N11,L11:L16/K11:K16)
12a26b2.8889=sumifs(L11:L16/K11:K16,J11:J16,N12)2.8889=sumif(J11:J16,N12,L11:L16/K11:K16)
13a36
14b38
15b414
16b25
Test
Cell Formulas
RangeFormula
O11O11=SUMIFS(T11:T16,J11:J16,N11)/COUNTIFS(J11:J16,N11)
O12O12=SUMIFS(T11:T16,J11:J16,N12)/COUNTIFS(J11:J16,N12)
Q11Q11=SUM(L11:L13/K11:K13)/3
Q12Q12=SUM(L14:L16/K14:K16)/3
 
Upvote 0

Forum statistics

Threads
1,216,808
Messages
6,132,822
Members
449,760
Latest member
letonuslepus

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