Average of last 3 numbers in non-continuous range

johannes2008

New Member
Joined
Aug 20, 2010
Messages
45
Office Version
  1. 365
Platform
  1. Windows
Hello

I am working on on a spreadsheet that uses the average of the last three months "actual" data to forecast the rest of the fiscal year. As "actual" data is entered for the next month I want the forecast value to update. To add to the complexity my "actual" data cells are non-continuous and not every cell has numbers in it. As well I want it to use the 4th, 3rd, and 2nd last data points as the last data point if for the current month and not complete yet.

1677276228879.png


So in the above example for row 4 the formula should take K4, H4 & E4, average them and return the value to S4. The formula should not use Q4 because it is empty nor use N4 as that is the current month and the data is not complete. However once a number is present in Q4 it should then use H4, K4 & N4 to calculate the average.

I hope this makes sense

Thanks
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
will you be continuing to add columns for each month as your year progresses? Have you considered putting the data in to columns and then using a pivot report to get the data you need?

Also, we need to know what version of excel you are using as solutions can drastically vary (or even not exist) depending on that. you should update your profile so the version(s) you use are displayed with your profile avatar in the messages.
 
Upvote 0
try this:
Book1
EHKNQS
1if q blank dn use n
2
3
4591018
55910156.666667
Sheet2
Cell Formulas
RangeFormula
S4:S5S4=AVERAGE(H4,K4,IF(ISBLANK(Q4),E4,N4))
 
Upvote 0
will you be continuing to add columns for each month as your year progresses? Have you considered putting the data in to columns and then using a pivot report to get the data you need?

Also, we need to know what version of excel you are using as solutions can drastically vary (or even not exist) depending on that. you should update your profile so the version(s) you use are displayed with your profile avatar in the messages.
The data will go from Jan 2023 to Mar 2024 and we use Excel 365.
 
Upvote 0
okay, the formula I give above will work if you insert the exact same number of columns with each new month.
 
Upvote 0
Okay, yeah, it will be clunky. You'll have to COPY column S formulas to the 3rd column over, then delete column S. You will have DIV/0 errors until you enter updated data. If you insert columns then you'll have to update the cell references in the formulas and copy them down.
 
Upvote 0
So in the above example for row 4 the formula should take K4, H4 & E4, average them and return the value to S4.
What should happen in row 5?
What should happen if any row has some values but not enough to collect 3 relevant values?

More examples and expected results with XL2BB would be helpful.
 
Upvote 0
What should happen in row 5?
What should happen if any row has some values but not enough to collect 3 relevant values?

More examples and expected results with XL2BB would be helpful.
Good question Peter. But, I was going on what the OP said by only data missing in the most recent full month. If it is blank, I guess the average array will have a blank value in it.
 
Upvote 0
Pending answers to the above, you could test this as a starting point.

23 02 25.xlsm
ABCDEFGHIJKLMNOPQRS
2OctNovDecJanFebMar
3
4155595105158
Average
Cell Formulas
RangeFormula
S4S4=LET(f,FILTER(B4:R4,(B2:R2<>"")*(B4:R4<>"")),AVERAGE(INDEX(f,,SEQUENCE(,3,COLUMNS(f)-1,-1))))
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

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