Formula to work out the average value of the most recent entries v2

Jonny_71

New Member
Joined
Sep 12, 2017
Messages
12
Office Version
  1. 365
1605383738854.png



Hi,

In the example above, in cell F26 if I wanted to calculate the average number of goals scored by Team A in the preceding three weeks what would the formula be?

So the answer would be 0.67 (average of 1 + 1 + 0) for the previous three weeks. I've tried but I just can't get it right.

Thank you.

Also asked here Formula to calculate average of most recent values
 
Last edited by a moderator:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi Jonny_71,

I changed the date format as I'm using a US PC.
You don't define "for the previous three weeks" so I'm assuming it's 3 weeks before the last date shown (cell G2).
The answer you seek is in cell I2 which uses SUMIFS to add all Home and Away scores for the Team in H2 from the calculated date by the COUNTIF the team in H2 appears from the specified date in Home or Away columns.

Jonny_71.xlsx
ABCDEFGHI
1DateHomeAwayScoreScoreDateTeamAnswer
201-Jan-20Team ATeam F1109-Jan-20Team A0.666667
301-Jan-20Team BTeam G41
401-Jan-20Team CTeam H10
501-Jan-20Team DTeam I20
601-Jan-20Team ETeam J10
7
808-Jan-20Team FTeam A01
908-Jan-20Team GTeam B11
1008-Jan-20Team HTeam C21
1108-Jan-20Team ITeam D23
1208-Jan-20Team JTeam E00
13
1415-Jan-20Team ATeam G14
1515-Jan-20Team BTeam H03
1615-Jan-20Team CTeam I10
1715-Jan-20Team DTeam J20
1815-Jan-20Team ETeam F32
19
2022-Jan-20Team FTeam B20
2122-Jan-20Team GTeam C12
2222-Jan-20Team HTeam D13
2322-Jan-20Team ITeam E02
2422-Jan-20Team JTeam A40
25
2629-Jan-20Team ATeam H12
2729-Jan-20Team BTeam I20
2829-Jan-20Team CTeam J10
2929-Jan-20Team DTeam F22
3029-Jan-20Team ETeam G03
Sheet1
Cell Formulas
RangeFormula
G2G2=MAX(A:A)-20
I2I2=(SUMIFS(D:D,A:A,">="&$G$2,B:B,$H$2)+SUMIFS(E:E,A:A,">="&$G$2,C:C,$H$2))/(COUNTIFS(A:A,">="&$G$2,B:B,$H$2)+COUNTIFS(A:A,">="&$G$2,C:C,$H$2))
 
Upvote 0
Hi Jonny_71,

I changed the date format as I'm using a US PC.
You don't define "for the previous three weeks" so I'm assuming it's 3 weeks before the last date shown (cell G2).
The answer you seek is in cell I2 which uses SUMIFS to add all Home and Away scores for the Team in H2 from the calculated date by the COUNTIF the team in H2 appears from the specified date in Home or Away columns.

Jonny_71.xlsx
ABCDEFGHI
1DateHomeAwayScoreScoreDateTeamAnswer
201-Jan-20Team ATeam F1109-Jan-20Team A0.666667
301-Jan-20Team BTeam G41
401-Jan-20Team CTeam H10
501-Jan-20Team DTeam I20
601-Jan-20Team ETeam J10
7
808-Jan-20Team FTeam A01
908-Jan-20Team GTeam B11
1008-Jan-20Team HTeam C21
1108-Jan-20Team ITeam D23
1208-Jan-20Team JTeam E00
13
1415-Jan-20Team ATeam G14
1515-Jan-20Team BTeam H03
1615-Jan-20Team CTeam I10
1715-Jan-20Team DTeam J20
1815-Jan-20Team ETeam F32
19
2022-Jan-20Team FTeam B20
2122-Jan-20Team GTeam C12
2222-Jan-20Team HTeam D13
2322-Jan-20Team ITeam E02
2422-Jan-20Team JTeam A40
25
2629-Jan-20Team ATeam H12
2729-Jan-20Team BTeam I20
2829-Jan-20Team CTeam J10
2929-Jan-20Team DTeam F22
3029-Jan-20Team ETeam G03
Sheet1
Cell Formulas
RangeFormula
G2G2=MAX(A:A)-20
I2I2=(SUMIFS(D:D,A:A,">="&$G$2,B:B,$H$2)+SUMIFS(E:E,A:A,">="&$G$2,C:C,$H$2))/(COUNTIFS(A:A,">="&$G$2,B:B,$H$2)+COUNTIFS(A:A,">="&$G$2,C:C,$H$2))
That's so helpful, thank you Toadstool.
 
Upvote 0
If you have the FILTER function in your Excel 365 then you could also try this

20 11 15.xlsm
ABCDEFGHI
1DateHomeAwayScoreScoreTeamAnswer
21/01/2020Team ATeam F11Team A0.666666667
31/01/2020Team BTeam G41
41/01/2020Team CTeam H10
51/01/2020Team DTeam I20
61/01/2020Team ETeam J10
7
88/01/2020Team FTeam A01
98/01/2020Team GTeam B11
108/01/2020Team HTeam C21
118/01/2020Team ITeam D23
128/01/2020Team JTeam E00
13
1415/01/2020Team ATeam G14
1515/01/2020Team BTeam H03
1615/01/2020Team CTeam I10
1715/01/2020Team DTeam J20
1815/01/2020Team ETeam F32
19
2022/01/2020Team FTeam B20
2122/01/2020Team GTeam C12
2222/01/2020Team HTeam D13
2322/01/2020Team ITeam E02
2422/01/2020Team JTeam A40
25
2629/01/2020Team ATeam H12
2729/01/2020Team BTeam I20
2829/01/2020Team CTeam J10
2929/01/2020Team DTeam F22
3029/01/2020Team ETeam G03
31
32
Average
Cell Formulas
RangeFormula
I2I2=AVERAGE(FILTER(IF(B2:B300=H2,D2:D300,IF(C2:C300=H2,E2:E300)),A2:A300>MAX(A2:A300)-21))
 
Upvote 0
If you have the FILTER function in your Excel 365 then you could also try this

20 11 15.xlsm
ABCDEFGHI
1DateHomeAwayScoreScoreTeamAnswer
21/01/2020Team ATeam F11Team A0.666666667
31/01/2020Team BTeam G41
41/01/2020Team CTeam H10
51/01/2020Team DTeam I20
61/01/2020Team ETeam J10
7
88/01/2020Team FTeam A01
98/01/2020Team GTeam B11
108/01/2020Team HTeam C21
118/01/2020Team ITeam D23
128/01/2020Team JTeam E00
13
1415/01/2020Team ATeam G14
1515/01/2020Team BTeam H03
1615/01/2020Team CTeam I10
1715/01/2020Team DTeam J20
1815/01/2020Team ETeam F32
19
2022/01/2020Team FTeam B20
2122/01/2020Team GTeam C12
2222/01/2020Team HTeam D13
2322/01/2020Team ITeam E02
2422/01/2020Team JTeam A40
25
2629/01/2020Team ATeam H12
2729/01/2020Team BTeam I20
2829/01/2020Team CTeam J10
2929/01/2020Team DTeam F22
3029/01/2020Team ETeam G03
31
32
Average
Cell Formulas
RangeFormula
I2I2=AVERAGE(FILTER(IF(B2:B300=H2,D2:D300,IF(C2:C300=H2,E2:E300)),A2:A300>MAX(A2:A300)-21))
That's great. Thank you for your help, Peter.
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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