Array Formula With Sumproduct for Average

scottlockhart

New Member
Joined
Feb 24, 2016
Messages
8
I have two questions. First, I'm using an array formula in my last column (H) to average the percentages in column B, based on the day in column C. (the data is truncated FIY)
Ex: {=AVERAGE(IF$C$5:$C34=E5,$B$5:$B$34))}

My first question is: how do I embed SUMPRODUCT into the formula (replacing AVERAGE I assume) to base the averages from column B off of the corresponding weights from column A?

Second question: My Day 0 array formula is not working properly. I'm assuming it has to do with the "0", but the AVERAGE function shouldn't be picking up blank cells anyway, should it? Based on the data it should be 100+100+100+100+61.11+27.27+60.00+11.11/8 which equals 69.94%, not 9.07%.

I appreciate anyone's help!
2100.00%
2100.00%0Day 09.07%
1100.00%Day 110.10%
1100.00%0Day 2#DIV/0!
3100.00%Day 3#DIV/0!
3100.00%0Day 4#DIV/0!
4100.00%Day 5#DIV/0!
4100.00%0Day 6#DIV/0!
18100.00%Day 7#DIV/0!
1161.11%0Day 8#DIV/0!
15.56%20Day 9#DIV/0!
15.56%68Day 10#DIV/0!
15.56%99Day 11#DIV/0!
15.56%118Day 12#DIV/0!
15.56%178Day 13#DIV/0!
15.56%188Day 14#DIV/0!
15.56%194Day 15#DIV/0!
11100.00%Day 16#DIV/0!
327.27%0Day 17#DIV/0!
19.09%1Day 18#DIV/0!
19.09%30Day 19#DIV/0!
19.09%58Day 205.56%
19.09%60Day 21#DIV/0!
19.09%91Day 22#DIV/0!
19.09%121Day 23#DIV/0!
19.09%152Day 24#DIV/0!
19.09%183Day 25#DIV/0!
5100.00%Day 26#DIV/0!
360.00%0Day 27#DIV/0!
120.00%30Day 28#DIV/0!
120.00%60Day 29#DIV/0!
9100.00%Day 3014.55%
888.89%0
111.11%1

<colgroup><col width="64" style="width:48pt"> <col width="64" style="width:48pt"> <col width="64" span="4" style="width:48pt"> <col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>

<colgroup><col width="64" style="width:48pt"> <col width="64" style="width:48pt"> <col width="64" span="4" style="width:48pt"> <col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>

<colgroup><col width="64" style="width:48pt"> <col width="64" style="width:48pt"> <col width="64" span="4" style="width:48pt"> <col width="64" style="width:48pt"> </colgroup><tbody>
</tbody>
 
What do we have in C? What do we correlated day 0 with the data in A:C?

Column C are days that correspond with days in column F.

Ex: cells C20 and C34 match up with F1, and the corresponding percentages in column B are averaged into column G & H (one is weighted, one is not).
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
See if this is what you want.
If all the days in F will match up with a day in column C we could do away with the IF part of the formula.
Formula in G2 is an array formula and must be entered with CTRL-SHIFT-ENTER.

Also what ver. of Excel are you using?
Excel Workbook
ABCDEFGH
1WeightPercentDayCriteria (Day)AverageWt. Average
22100.00%Day092.22%79.63%
32100.00%0Day1
41100.00%Day2
51100.00%0Day3
63100.00%5Day4
73100.00%0Day572.50%68.57%
8445.00%5Day6
94100.00%0Day7
1018100.00%Day8
111161.11%0Day9
1215.56%10Day105.56%5.56%
Sheet
 
Upvote 0
Column C are days that correspond with days in column F.

Ex: cells C20 and C34 match up with F1, and the corresponding percentages in column B are averaged into column G & H (one is weighted, one is not).

Row\Col
A​
B​
C​
F​
G​
H​
1​
2
100.00%
Average
Wt. Average
2​
2
100.00%
0
0
79.66%
227.00%
3​
1
100.00%
1
10.10%
10.10%
4​
1
100.00%
0
2
5​
3
100.00%
3
6​
3
100.00%
0
4
7​
4
100.00%
5
8​
4
100.00%
0
6
9​
18
100.00%
7
10​
11
61.11%
0
8
11​
1
5.56%
20
9
12​
1
5.56%
68
10
13​
1
5.56%
99
11
14​
1
5.56%
118
12
15​
1
5.56%
178
13
16​
1
5.56%
188
14
17​
1
5.56%
194
15
18​
11
100.00%
16
19​
3
27.27%
0
17
20​
1
9.09%
1
18
21​
1
9.09%
30
19
22​
1
9.09%
58
20
5.56%
5.56%
23​
1
9.09%
60
21
24​
1
9.09%
91
22
25​
1
9.09%
121
23
26​
1
9.09%
152
24
27​
1
9.09%
183
25
28​
5
100.00%
26
29​
3
60.00%
0
27
30​
1
20.00%
30
28
31​
1
20.00%
60
29
32​
9
100.00%
30
14.55%
14.55%
33​
8
88.89%
0
34​
1
11.11%
1

In G2 just enter and copy down:

=IF(ISNUMBER(MATCH(F2,$C$1:$C$34,0)),AVERAGEIFS($B$1:$B$34,$C$1:$C$34,$F2),"")

In H2 just enter and copy down:

=IF(ISNUMBER($G2),SUMPRODUCT(--($C$1:$C$34=$F2),$B$1:$B$34,$A$1:$A$34)/SUMIFS($A$1:$A$34,$C$1:$C$34,$F2),"")

Is the foregoing what you are after?
 
Upvote 0

Forum statistics

Threads
1,215,364
Messages
6,124,507
Members
449,166
Latest member
hokjock

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