Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

Calculating Moving Average in Excel

Uploaded by

Farook Shaikh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Calculating Moving Average in Excel

Uploaded by

Farook Shaikh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

CALCULATING MOVING AVERAGE IN EXCEL

What is moving average?

Generally speaking, moving average (also referred to as rolling average, running


average or moving mean) can be defined as a series of averages for different subsets of the same
data set.

A moving average (MA) is a statistical technique used to smooth out short-term


fluctuations in a time series data set, highlighting longer-term trends and patterns.

It is frequently used in statistics, seasonally-adjusted economic and weather forecasting to


understand underlying trends. In stock trading, moving average is an indicator that shows the
average value of a security over a given period of time. In business, it's a common practice to
calculate a moving average of sales for the last 3 months to determine the recent trend.

Types of Moving Averages:

1. Simple Moving Average (SMA): Calculates the average of a fixed number of past data points.

2. Exponential Moving Average (EMA): Gives more weight to recent data points.

3. Weighted Moving Average (WMA): Assigns weights to data points based on their relative importance.

4. Cumulative Moving Average (CMA): Calculates the average of all data points up to the current point.

How Moving Averages Work:

1. Choose a time period (e.g., 50-day MA).


2. Calculate the average of the data points for that period.
3. As new data points are added, remove the oldest data point and recalculate the average.

Advantages:

1. Reduces noise and volatility


2. Highlights trends and patterns
3. Easy to calculate and interpret
4. Useful for forecasting
Disadvantages:
1. Lagging indicator (reacts to past data)
2. Sensitive to time period chosen
3. May not capture sudden changes
4. Overly relies on historical data
For example, the moving average of three-month temperatures can be calculated by taking the
average of temperatures from January to March, then the average of temperatures from February
to April, then of March to May, and so on.

There exist different types of moving average such as simple (also known as arithmetic),
exponential, variable, triangular, and weighted. In this tutorial, we will be looking into the most
commonly used simple moving average.

Calculate moving average for a certain time period

A simple moving average can be calculated in no time with the AVERAGE function. Supposing
you have a list of average monthly temperatures in column B, and you want to find a moving
average for 3 months (as shown in the image above).

Write a usual AVERAGE formula for the first 3 values and input it in the row corresponding to
the 3rd value from the top (cell C4 in this example), and then copy the formula down to other
cells in the column:

=AVERAGE(B2:B4)
You can fix the column with an absolute reference (like $B2) if you want to, but be sure to
use relative row references (without the $ sign) so that the formula adjusts properly for other
cells.

Remembering that an average is computed by adding up values and then dividing the sum by the
number of values to be averaged, you can verify the result by using the SUM formula:

=SUM(B2:B4)/3

Get moving average for a the last N days / weeks / months/ years in a column

Supposing you have a list of data, e.g. sale figures or stock quotes, and you want to know the
average of the last 3 months at any point of time. For this, you need a formula that will
recalculate the average as soon as you enter a value for the next month. What Excel function is
capable of doing this? The good old AVERAGE in combination with OFFSET and COUNT.

=AVERAGE(OFFSET(first cell, COUNT(entire range)-N,0,N,1))

Where N is the number of the last days / weeks / months/ years to include in the average.

Assuming that the values to average are in column B beginning in row 2, the formula would be
as follows:

=AVERAGE(OFFSET(B2,COUNT(B2:B100)-3,0,3,1))
And now, let's try to understand what this Excel moving average formula is actually doing.

 The COUNT function COUNT(B2:B100) counts how many values are already entered in
column B. We start counting in B2 because row 1 is the column header.

 The OFFSET function takes cell B2 (the 1st argument) as the starting point, and offsets the count
(the value returned by the COUNT function) by moving 3 rows up (-3 in the 2 nd argument). As
the result, it returns the sum of values in a range consisting of 3 rows (3 in the 4 th argument) and
1 column (1 in the last argument), which is the latest 3 months that we want.

 Finally, the returned sum is passed to the AVERAGE function to calculate the moving average.

Tip. If you are working with continuously updatable worksheets where new rows are likely to be
added in the future, be sure to supply a sufficient number of rows to the COUNT function to
accommodate potential new entries. It's not a problem if you include more rows than actually
needed as long as you have the first cell right, the COUNT function will discard all empty rows
anyway.

As you probably noticed, the table in this example contains data for only 12 months, and yet the
range B2:B100 is supplied to COUNT, just to be on the save side :)
Find moving average for the last N values in a row

If you want to calculate a moving average for the last N days, months, years, etc. in the same
row, you can adjust the Offset formula in this way:

=AVERAGE(OFFSET(first cell,0,COUNT(range)-N,1,N,))

Supposing B2 is the first number in the row, and you want to include the last 3 numbers in the
average, the formula takes the following shape:

=AVERAGE (OFFSET(B2,0,COUNT(B2:N2)-3,1,3))
Creating an Excel moving average chart

If you have already created a chart for your data, adding a moving average trendline for that
chart is a matter of seconds. For this, we are going to use Excel Trendline feature and the
detailed steps follow below.

For this example, I've created a 2-D column chart (Insert tab > Charts group) for our sales data:

And now, we want to "visualize" the moving average for 3 months.

1. In Excel 2013, select the chart, go to the Design tab > Chart Layouts group, and click Add
Chart Element > Trendline > More Trendline Options…
1. In Excel 2010 and Excel 2007, go to Layout > Trendline > More Trendline Options.

Tip. If you do not need to specify the details such as the moving average interval or names,
you can click Design > Add Chart Element > Trendline > Moving Average for the immediate
result.

2. The Format Trendline pane will open on the right-hand side of your worksheet in Excel 2013,
and the corresponding dialog box will pop up in Excel 2010 and 2007.

On the Format Trendline pane, you click the Trendline Options icon, select the Moving
Average option and specify the moving average interval in the Period box:
3. Close the Trendline pane and you will find the moving average trendline added to your
chart:

To refine your chat, you can switch to the Fill & Line or Effects tab on the Format
Trendline pane and play with different options such as line type, color, width, etc.
For powerful data analysis, you may want to add a few moving average trendlines with
different time intervals to see how the trend evolves. The following screenshot shows the
2-month (green) and 3-month (brick red) moving average trendlines:

You might also like