Skipping blank cells in moving average calculations

BigBucks

New Member
Joined
Jun 30, 2011
Messages
1
2008 for Mac. Version 12.3.0.

I want to calculate the moving average value of the last x data points in a time series (column), without using or discarding all the blank cells in that column.

What I do now in Excel is make a new counter column to keep the original order for later. Then add another column which I populate with a 1 (a dummy variable) if there is a value, or 0 if no value. Then I sort the entire section, moving the 1's to the top, along with all the other data. Next I calculate the avg values (say avg of last 5) in a new column. Then overwrite that with the "paste special" "values" in those cells. Then re-sort by time. Then, for blank cells in the re-sorted column, I use the value from the cell above, if blank.

That is not all that hard, but there must be a command in Excel that uses the prior x number of values, to do the calculation, which ignores the blanks in between. Then I could do all of the above in one step. Do you happen to know such a function or formula?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,224,548
Messages
6,179,451
Members
452,915
Latest member
hannnahheileen

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