How to Calculate Moving Average in Excel

A moving average smooths out short-term fluctuations in data to reveal underlying trends. Instead of looking at individual data points that jump around, you calculate the average of a fixed number of...

Key Insights

  • Excel offers multiple methods for calculating moving averages: the AVERAGE function for manual control, OFFSET for dynamic ranges, and the Analysis ToolPak for quick batch processing—choose based on your dataset size and update frequency.
  • A 3-period moving average works well for daily data with high volatility, while 7-period or longer windows suit weekly trends; the optimal window size depends on balancing responsiveness against noise reduction.
  • Exponential moving averages weight recent data more heavily than simple moving averages, making them superior for financial analysis and real-time forecasting where current trends matter more than historical patterns.

Introduction to Moving Averages

A moving average smooths out short-term fluctuations in data to reveal underlying trends. Instead of looking at individual data points that jump around, you calculate the average of a fixed number of consecutive values—this “window” moves through your dataset, creating a smoother line that’s easier to interpret.

You’ll use moving averages constantly in real-world analysis. Track sales trends by smoothing daily revenue into weekly patterns. Analyze stock prices to identify buy/sell signals when short-term averages cross long-term ones. Monitor manufacturing quality by detecting when moving averages drift outside acceptable ranges.

Two types dominate: Simple Moving Average (SMA) treats all values in the window equally—a 5-day SMA averages the last 5 days with equal weight. Exponential Moving Average (EMA) weights recent values more heavily, making it more responsive to changes. Start with SMA for most use cases; move to EMA when you need faster reaction to trends.

Using Excel’s Built-in AVERAGE Function

The AVERAGE function gives you complete control over moving average calculations. This manual approach works best for smaller datasets or when you need to understand exactly what’s happening.

Start with a simple dataset. Put dates in column A and values in column B. For a 3-period moving average, click cell C4 (the third row of data, since you need three values to average). Enter this formula:

=AVERAGE(B2:B4)

This averages cells B2, B3, and B4. The key insight: when you copy this formula down, Excel automatically adjusts the range. Cell C5 becomes =AVERAGE(B3:B5), C6 becomes =AVERAGE(B4:B6), and so on. You’ve created a moving window.

For a 7-period moving average, start at row 8 (the seventh data row) and use:

=AVERAGE(B2:B8)

Copy this down through your dataset. You’ll notice the first few rows remain empty—this is correct. You can’t calculate a 7-period average until you have 7 data points.

Here’s a practical example with sales data:

A          B        C (3-period MA)
Date       Sales    Formula
1/1/2024   1200     
1/2/2024   1350     
1/3/2024   1180     =AVERAGE(B2:B4)  → 1243.33
1/4/2024   1420     =AVERAGE(B3:B5)  → 1316.67
1/5/2024   1290     =AVERAGE(B4:B6)  → 1296.67

The moving average lags behind the actual data—this is inherent to the technique. When sales spike to 1420 on 1/4, the moving average only reaches 1316.67 because it includes the previous lower values.

Dynamic Moving Averages with OFFSET Function

The AVERAGE approach requires manual adjustment if you change the window size. The OFFSET function solves this by creating dynamic ranges that reference a variable number of cells.

OFFSET takes five arguments: starting reference, rows to move, columns to move, height, and width. For moving averages, you’ll use it to create a range that always looks back a fixed number of rows.

Here’s a 3-period trailing average using OFFSET:

=AVERAGE(OFFSET(B4,0,0,-3,1))

Breaking this down: Start at B4 (current row), move 0 rows down, 0 columns right, create a range -3 rows high (going upward to include B2, B3, B4), and 1 column wide. This creates the range B2:B4 dynamically.

The power comes when you make the window size a parameter. Put your desired period (like 3, 7, or 14) in cell E1. Then use:

=AVERAGE(OFFSET(B4,0,0,-$E$1,1))

Now you can change E1 to instantly recalculate all moving averages with a different window size. The dollar signs make E1 an absolute reference that doesn’t change when you copy the formula.

For a centered moving average (useful in some statistical applications), adjust the offset:

=AVERAGE(OFFSET(B4,-1,0,-3,1))

This starts one row above the current row, creating a window that includes one value before and one after the current point.

Creating Moving Averages with Data Analysis ToolPak

For large datasets, the Analysis ToolPak processes moving averages faster than manual formulas. This add-in comes with Excel but isn’t enabled by default.

Enable it: File → Options → Add-ins → Manage Excel Add-ins → Go → Check “Analysis ToolPak” → OK.

Once enabled, navigate to Data tab → Data Analysis → Moving Average. A dialog box appears with three key settings:

  • Input Range: Select your data column including the header
  • Interval: Enter the number of periods (3, 7, 14, etc.)
  • Output Range: Choose where to place results

Check “Chart Output” to automatically generate a visualization. The tool creates a new column with moving average values and leaves the first N-1 cells empty (where N is your interval).

The ToolPak approach has limitations: it’s static (doesn’t update when source data changes) and only calculates simple moving averages. Use it for one-time analysis or reports. Use formulas for dashboards that need live updates.

Visualizing Moving Averages with Charts

Moving averages become actionable when you visualize them against raw data. Create a line chart that shows both series so you can spot trend changes.

Select your data range including dates, original values, and moving average column. Insert → Line Chart → Line with Markers. Excel creates two series automatically.

Format the moving average line differently: right-click the series → Format Data Series → Line Color → choose a contrasting color and increase line width to 2-3pt. Remove markers from the moving average to keep it clean.

For multiple moving averages (comparing 3-period vs 7-period trends), add both columns to your chart:

A          B        C (3-MA)   D (7-MA)
Date       Sales    Formula    Formula
1/1/2024   1200                
1/2/2024   1350                
1/3/2024   1180     1243       
1/4/2024   1420     1317       
1/5/2024   1290     1297       
1/6/2024   1380     1363       
1/7/2024   1310     1327       
1/8/2024   1450     1380       1326

The 3-period average (blue line) follows the data more closely. The 7-period average (red line) shows the broader trend with less noise. This dual-view helps distinguish temporary fluctuations from meaningful changes.

Add a trendline directly to existing charts: right-click a data series → Add Trendline → Moving Average → set period. This quick method works for presentations but gives you less control than calculated columns.

Advanced Techniques: Weighted and Exponential Moving Averages

Simple moving averages treat all values equally, but sometimes recent data matters more. Weighted moving averages (WMA) assign higher weights to newer values.

For a 3-period WMA with weights 3, 2, 1 (most recent to oldest):

=(B4*3 + B3*2 + B2*1) / 6

The denominator is the sum of weights (3+2+1=6). This gives the most recent value three times the influence of the oldest value.

Exponential moving averages take this further with a smoothing factor (alpha) that determines responsiveness. The formula is:

EMA = (Value * Alpha) + (Previous_EMA * (1 - Alpha))

For a 10-period EMA, alpha is typically 2/(10+1) = 0.1818. In Excel, starting at row 3 with the previous EMA in C2:

=B3*0.1818 + C2*(1-0.1818)

Or more explicitly:

=B3*0.1818 + C2*0.8182

For the first EMA value (C2), use a simple average of the first N periods as a seed value. Then let the exponential formula take over from C3 downward.

A practical implementation with alpha in cell E1:

=B3*$E$1 + C2*(1-$E$1)

Higher alpha values (0.3-0.5) make the EMA more responsive—it reacts quickly to changes but includes more noise. Lower values (0.1-0.2) create smoother lines that lag more behind actual data. Financial analysts often use 12-period and 26-period EMAs together to generate trading signals.

Practical Applications and Best Practices

Choosing the right window size determines whether your moving average reveals insights or obscures them. Too small (2-3 periods) barely smooths the data. Too large (30+ periods) over-smooths and lags far behind current trends.

Start with these guidelines:

  • Daily data with high volatility: 3-5 period MA for short-term, 10-20 for medium-term trends
  • Weekly data: 4-week (monthly) or 13-week (quarterly) windows
  • Monthly data: 3-month or 12-month (annual) windows
  • Financial data: 50-day and 200-day MAs are industry standards

Handle edge cases deliberately. The beginning of your dataset can’t have moving average values until you accumulate enough periods. Either leave these cells empty or use expanding windows (average of all available data up to that point) for the first N-1 rows.

At the end of your dataset, consider whether to include partial windows. For forecasting, use only complete windows to maintain consistency. For historical analysis, partial windows at the end help visualize the most recent trend.

Common pitfalls to avoid:

Centering confusion: Trailing moving averages (most common) use only past data. Centered moving averages use data before and after each point—they look smoother but can’t be used for real-time forecasting since future data isn’t available yet.

Mixing period types: Don’t compare a 7-day MA with a 4-week MA as if they’re equivalent. Seven days is one week; four weeks is 28 days. Keep your time units consistent.

Over-reliance on smoothing: Moving averages remove volatility, which sometimes contains important signals. Always plot raw data alongside moving averages. A sudden spike might be an outlier to ignore or a critical event to investigate.

Ignoring calculation lag: A 20-period moving average responds to changes 10 periods later than a 10-period average. In fast-moving situations, this lag can make your analysis obsolete before you act on it.

Test different window sizes with your specific data. Calculate 3, 7, 14, and 30-period moving averages simultaneously, plot them together, and see which best balances smoothness against responsiveness for your use case. The “right” answer depends on your data’s characteristics and your analysis goals.

Liked this? There's more.

Every week: one practical technique, explained simply, with code you can use immediately.