Find Average for n 3 month across columns

Liz_I3

Well-known Member
Joined
Dec 30, 2002
Messages
647
Office Version
  1. 2016
Platform
  1. Windows
Hello I want the average of the current last 3 month on my spreadsheet. .Below is a copy of what my spreadsheet looks like it show the average for Dec, Jan & Feb (which I just keyed in) Next month I would want the average for Jan, Feb & Mar. etc
I found this formula but it just does not do it. Average(Offset( C2,0,Count(C2:P2)-3,1,3)).


11/01/20​
12/01/20​
01/01/21​
02/01/21​
03/01/21​
04/01/21​
05/01/21​
06/01/21​
07/01/21​
08/01/21​
09/01/21​
10/01/21​
11/01/21​
12/01/21​
Average
10​
20​
30​
40​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
30​

Thanks for taking the time to help

L
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try:

Book1
ABCDEFGHIJKLMNO
111/01/2012/01/2001/01/2102/01/2103/01/2104/01/2105/01/2106/01/2107/01/2108/01/2109/01/2110/01/2111/01/2112/01/21Average
210203040000000000025
Sheet2
Cell Formulas
RangeFormula
O2O2=AVERAGE(A2:INDEX(A2:N2,LOOKUP(2,1/(A2:N2<>0),COLUMN(A2:N2))))


This finds the last non-zero number, and averages everything before that, inclusive.
 
Upvote 0
I think the OP wanted the last 3 months, not everything before the last 0.

Depending on your version of Excel, here are some options.

FactSheet_Data_New (8).xlsx
ABCDEFGHIJKLMNOPQ
111/1/202012/1/20201/1/20212/1/20213/1/20214/1/20215/1/20216/1/20217/1/20218/1/20219/1/202110/1/202111/1/202112/1/2021AverageAverageAverage
21020304050000000000404040
Sheet1
Cell Formulas
RangeFormula
O2O2=AVERAGE(INDEX(A2:N2,,ROW(INDIRECT(MATCH(EOMONTH(TODAY(),-1)+1,A1:N1,0)-2 &":" & MATCH(EOMONTH(TODAY(),-1)+1,A1:N1,0)))))
P2P2=AVERAGE(INDEX(A2:N2,,SEQUENCE(,3,MATCH(EOMONTH(TODAY(),-1)+1,A1:N1,0)-2)))
Q2Q2=AVERAGE(IF(ISNUMBER(MATCH(A1:N1,EOMONTH(TODAY(),{-1,-2,-3})+1,0)),A2:N2))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0
I think the OP wanted the last 3 months, not everything before the last 0.
D'oh! ? Of course, I got off course somewhere.

Your formulas look like they are work by matching on the date, which should be fine. But just for informational purposes, here's where the original formula went awry:

Book1
ABCDEFGHIJKLMNO
111/01/2012/01/2001/01/2102/01/2103/01/2104/01/2105/01/2106/01/2107/01/2108/01/2109/01/2110/01/2111/01/2112/01/21Average
21020304030
Sheet2
Cell Formulas
RangeFormula
O2O2=AVERAGE(OFFSET(C2,0,COUNT(C2:N2)-3,1,3))


It works fine IF the cells after the last month are empty, not filled with zeros. If they do have zeros, a hybrid of the OP's original formula and my formula would work without using the date.
 
Upvote 0
I think the OP wanted the last 3 months, not everything before the last 0.

Depending on your version of Excel, here are some options.

FactSheet_Data_New (8).xlsx
ABCDEFGHIJKLMNOPQ
111/1/202012/1/20201/1/20212/1/20213/1/20214/1/20215/1/20216/1/20217/1/20218/1/20219/1/202110/1/202111/1/202112/1/2021AverageAverageAverage
21020304050000000000404040
Sheet1
Cell Formulas
RangeFormula
O2O2=AVERAGE(INDEX(A2:N2,,ROW(INDIRECT(MATCH(EOMONTH(TODAY(),-1)+1,A1:N1,0)-2 &":" & MATCH(EOMONTH(TODAY(),-1)+1,A1:N1,0)))))
P2P2=AVERAGE(INDEX(A2:N2,,SEQUENCE(,3,MATCH(EOMONTH(TODAY(),-1)+1,A1:N1,0)-2)))
Q2Q2=AVERAGE(IF(ISNUMBER(MATCH(A1:N1,EOMONTH(TODAY(),{-1,-2,-3})+1,0)),A2:N2))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
HI Irobbo314
I used your first suggestion =AVERAGE(IF(ISNUMBER(MATCH(A1:N1,EOMONTH(TODAY(),{-1,-2,-3})+1,0)),A2:N2)) and it is working well

My version of excel 2016 did not recognize ,SEQUENCE I got a # NAME? error.

Thank you very much for your time.
D'oh! ? Of course, I got off course somewhere.

Your formulas look like they are work by matching on the date, which should be fine. But just for informational purposes, here's where the original formula went awry:

Book1
ABCDEFGHIJKLMNO
111/01/2012/01/2001/01/2102/01/2103/01/2104/01/2105/01/2106/01/2107/01/2108/01/2109/01/2110/01/2111/01/2112/01/21Average
21020304030
Sheet2
Cell Formulas
RangeFormula
O2O2=AVERAGE(OFFSET(C2,0,COUNT(C2:N2)-3,1,3))


It works fine IF the cells after the last month are empty, not filled with zeros. If they do have zeros, a hybrid of the OP's original formula and my formula would work without using the date.
Hi Eric
Thank you for looking at this for me. I thought my formula would have worked also but I get a result for only the last 3 months not the 3 months that I wanted Dec, Jan & Feb
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,186
Members
449,071
Latest member
cdnMech

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