Moving Average

Steve 1962

Active Member
Joined
Jan 3, 2006
Messages
346
Office Version
  1. 365
Platform
  1. Windows
Hi All

I have a formula in column H that seems to be incorrect. I need it to give me a moving average based on column F. I need to be able to adjust the moving average from a value set in cell A1 (could be 5 week moving average or as in this case, 8 week moving average). Obviously the first output based on 8 week moving average would show in cell H9.

Also, is it possible to change from an moving AVERAGE to a moving MEDIAN ?

Thanks




8WeekZeroLowerUpperSection ASection BMoving AV
21030309107#VALUE!
2203030177#VALUE!
2303030990#VALUE!
2403030836#VALUE!
25030302042#VALUE!
260303017120#VALUE!
2703030949#VALUE!
2803030514#VALUE!??
2903030-1655#VALUE!
30030305114#VALUE!
3103030-1951#VALUE!
3203030-3118#VALUE!
3303030453#VALUE!
3403030-939#VALUE!
35030302678#VALUE!
3603030636#VALUE!
3703030382#VALUE!
3803030-1682#VALUE!
390303033119#VALUE!
4003030-1045#VALUE!
4103030-5103#VALUE!
4203030-4182#VALUE!
43030302787#VALUE!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Maybe:
Book1.xlsm
ABCDEFGH
18WeekZeroLowerUpperSection ASection BMoving AV
221030309.5107.5 
32203030177 
423030308.590 
52403030836 
6250303020.542.5 
7260303017120 
82703030949 
928030305149.8125
102903030-15.5556.6875
11300303051147.1875
123103030-18.5513.8125
133203030-3117.52.4375
1433030304.553.50.4375
153403030-939.5-2.8125
16350303026.578.5-0.625
173603030636.5-0.5
1837030303821.8125
193803030-1682-0.8125
20390303033.5118.55.6875
214003030-9.5454.875
224103030-51033.6875
234203030-4182-0.3125
2443030302787-0.25
Sheet7
Cell Formulas
RangeFormula
H2:H24H2=IF(B2<28,"",AVERAGE(OFFSET(F2,-7,0,8)))
 
Upvote 0
Hey thanks JoeMo -

Just a comment -

The value in cell B2 (in this case 21) may change. If so, how do I stil show blanks in column H ? The value of 28 in the formula would not apply.

Thanks
 
Upvote 0
Hey thanks JoeMo -

Just a comment -

The value in cell B2 (in this case 21) may change. If so, how do I stil show blanks in column H ? The value of 28 in the formula would not apply.

Thanks
You are welcome - thanks for the reply. The value in B2 should be less than the value in col B for the 8th week (in the example case that's 28).
 
Upvote 0
Solution
You are welcome - thanks for the reply. The value in B2 should be less than the value in col B for the 8th week (in the example case that's 28).
Sorry JoeMo, my mistake - I asked the wrong question with the last reply. I should have said that the value in B2 may commence at another week such as 7 or 16 or other (and not 21). Is so, that would make the hard-coded value of 28 in the formula incorrect. Instead of being set at 28, it needs to be dynamic based on what is the commencing week number (in cell B2).

Thanks
 
Upvote 0
Sorry JoeMo, my mistake - I asked the wrong question with the last reply. I should have said that the value in B2 may commence at another week such as 7 or 16 or other (and not 21). Is so, that would make the hard-coded value of 28 in the formula incorrect. Instead of being set at 28, it needs to be dynamic based on what is the commencing week number (in cell B2).

Thanks
You are welcome. To make it dynamic you can use this formula in H2 (where A1 holds the number of weeks you want to include in the moving average):
VBA Code:
=IF(B2<B$2+A$1-1,"",AVERAGE(OFFSET(F2,-A$1+1,0,A$1)))
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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