Using SUMPRODUCT instead of AVERAGEIFS due to Average Range <> Criteria Range size

Hawk11ns

Board Regular
Joined
Jul 21, 2015
Messages
61
Office Version
  1. 365
Platform
  1. Windows
I have 10 years worth of 24-hour data in range G3:P35162 and need to average only the data that meets the criteria of being equal to "Jan" in range A3:P35162 and "1" in range D3:D35162. I cannot perform this function using AVERAGEIFS since the ranges are not the same size, spanning multiple columns. I do recall coming across a solution, once before, using SUMPRODUCT - but for the life of me I cannot find it and every iteration I try does not work. Any guidance is much appreciated. Thanks!

1602089157746.png
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
If your version of Excel 365 has the FILTER function try the formula in L2, if not maybe the SUMPRODUCT formula in L5 in the example below. Change ranges to match your data. Also, I assumed the months in your column A are text and the numbers in column D are numeric. If they are actual dates formatted as mmm, then you will need to change the formulas.

Book1
ABCDEFGHIJKL
1MonthPeakCal DayHEIEDST2011201220132014Average
2Jan115.2536.7740.2344.3929.6525
3Jan134.1434.4342.7516.24
4Jan243.4244.235.8544.36
5Jan338.9742.2825.7244.2629.6525
6Jan227.2339.9834.2935.26
7Jan130.1812.2418.9226.95
8Jan120.8238.5126.6635.96
9Feb124.7238.3713.1216.46
10Feb122.611834.5536.04
11Feb221.3736.5641.3743.13
12Feb219.9439.7742.920.2
13Feb229.323.930.324.64
14Feb330.7312.8912.4514.02
15Feb417.1735.9127.2443.87
16Feb534.2730.1841.7441.04
Sheet1
Cell Formulas
RangeFormula
L2L2=AVERAGE(FILTER(G2:J16,($A$2:$A$16="Jan")*($D$2:$D$16=1)))
L5L5=SUMPRODUCT(($A$2:$A$16="Jan")*($D$2:$D$16=1)*(G2:J16))/SUMPRODUCT(($A$2:$A$16="Jan")*($D$2:$D$16=1)*(G2:J16/G2:J16))
 
Upvote 0
Without FILTER, this will work.

MrExcel posts18.xlsx
ABCDEFGHI
1MonthHE201120122013
2Jan1202017
3Jan1171324
4Jan1222325
5Jan1171018
6Jan3212217
7Feb2122013
8Feb4162312
9Feb1211716
10
11Criteria
12MonthHEsumcountaverageaverage (single-cell)
13Jan12261218.8333318.83333
Sheet48
Cell Formulas
RangeFormula
D13D13=SUMPRODUCT((A2:A9=A13)*(D2:D9=B13)*G2:I9)
E13E13=COUNT(1/((A2:A9=A13)*(D2:D9=B13)*G2:I9))
F13F13=D13/E13
G13G13=SUMPRODUCT((A2:A9=A13)*(D2:D9=B13)*G2:I9)/COUNT(1/((A2:A9=A13)*(D2:D9=B13)*G2:I9))
 
Upvote 0
If your version of Excel 365 has the FILTER function try the formula in L2, if not maybe the SUMPRODUCT formula in L5 in the example below. Change ranges to match your data. Also, I assumed the months in your column A are text and the numbers in column D are numeric. If they are actual dates formatted as mmm, then you will need to change the formulas.

Book1
ABCDEFGHIJKL
1MonthPeakCal DayHEIEDST2011201220132014Average
2Jan115.2536.7740.2344.3929.6525
3Jan134.1434.4342.7516.24
4Jan243.4244.235.8544.36
5Jan338.9742.2825.7244.2629.6525
6Jan227.2339.9834.2935.26
7Jan130.1812.2418.9226.95
8Jan120.8238.5126.6635.96
9Feb124.7238.3713.1216.46
10Feb122.611834.5536.04
11Feb221.3736.5641.3743.13
12Feb219.9439.7742.920.2
13Feb229.323.930.324.64
14Feb330.7312.8912.4514.02
15Feb417.1735.9127.2443.87
16Feb534.2730.1841.7441.04
Sheet1
Cell Formulas
RangeFormula
L2L2=AVERAGE(FILTER(G2:J16,($A$2:$A$16="Jan")*($D$2:$D$16=1)))
L5L5=SUMPRODUCT(($A$2:$A$16="Jan")*($D$2:$D$16=1)*(G2:J16))/SUMPRODUCT(($A$2:$A$16="Jan")*($D$2:$D$16=1)*(G2:J16/G2:J16))

Thanks for replying - I was completely unaware of the Office 365 filter function, and now I am totally in love with it! hahaha

Thanks again!
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

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