Use AVERAGEIFS based on dynamic criteria

BigTenBoy15

New Member
Joined
Feb 24, 2016
Messages
9
I'm trying to average a set of cells based on multiple criteria (hence the AVERAGEIFS), but I want this average to change as more data is added. There may be a very simple fix for this, but I can't figure it out for the life of me. Below is a sample of the table followed by an explanation of what I'm trying to achieve (this is for an NFL model I'm building)

PlayerWeekYardsGame Played
Me12001
You12001
Me21001
You21001
Me300
You33001
Me400
You43001
Me52001
You52001

<tbody>
</tbody>

Ideally, I'd like to be able to average the yards of a player over the past X number of weeks that person has played. For example, I'd like to be able to average the yards for the last 3 games that "Me" has played, which would be Weeks 5, 2, and 1 for an average of 166.67. Then, if I change the player's name to "You", the formula would calculate the average for Weeks 5, 4, and 3.

Furthermore, if I add a sixth week, I'd like it to then average Weeks 6, 5, and 2 as those would've been the last three weeks "Me" has played. Hopefully that makes sense and this isn't too complicated, but I appreciate any help!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try:

ABCDEFGH
1PlayerWeekYardsGame PlayedPlayer# of weeksAverage
2Me12001Me3116.6667
3You12001
4Me21001
5You21001
6Me300
7You33001
8Me400
9You43001
10Me52001
11You52001
12Me6501
13

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet10

Array Formulas
CellFormula
H2{=AVERAGE(N(OFFSET(C1,AGGREGATE(14,6,ROW(C2:C100)/(A2:A100=F2)/(D2:D100=1),ROW(INDIRECT("1:"&G2)))-1,0)))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,054
Latest member
juliecooper255

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