Cellwise Start free

Excel guide · 6 min read

How to calculate a moving average in Excel

Quick answerFor a 3-period moving average, type =AVERAGE(B2:B4) in the row of the third value (C4) and fill it down. Both ends of the range are relative, so each row averages itself and the two rows above it. For a 7 or 12-period average, widen the range to 7 or 12 rows and start the formula on the 7th or 12th value.

Sample data

Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.

ABCDE
1DateOrdersSettingValue
2Oct 19, 202642Window (rows)3
3Oct 20, 202638End dateOct 31, 2026
4Oct 21, 202645Weight, oldest1
5Oct 22, 202651Weight, middle2
6Oct 23, 202660Weight, newest3
7Oct 24, 202672
8Oct 26, 202640
9Oct 27, 202644
10Oct 28, 202647
11Oct 29, 202655
12Oct 30, 202663
13Oct 31, 202678

Download this sheet as an Excel practice file (.xlsx)

Method 1: a trailing average with a relative range

The sample sheet is a shop's daily orders for two weeks in October. The shop was closed on Sunday, October 25, so that date has no row. Daily numbers jump around, especially on weekends, and a moving average smooths them so you can see the trend.

In C4, next to October 21, type =AVERAGE(B2:B4). Fill it down to C13. C5 becomes =AVERAGE(B3:B5), C6 becomes =AVERAGE(B4:B6), and so on: the window moves down one row at a time. Leave C2 and C3 empty, because those days do not have three days behind them.

Do not use dollar signs here. =AVERAGE($B$2:B4) would anchor the top and give a running average of everything so far, which is a different measure.

=AVERAGE(B2:B4)

Result: 41.666666667 shows as 41.7 with Number format

41.7 for October 21. Filled down, the last row (October 31) shows 65.3.

Choose the window in one cell, blank until it is full

To try 3, 7 or 12 periods without rewriting the formula, put the window size in E2 and let the formula take the last E2 values from a growing range. In Excel 365 and 2024, type this in C2 and fill it down: =IF(ROWS($B$2:B2)<$E$2,"",AVERAGE(TAKE($B$2:B2,-$E$2))).

$B$2:B2 grows by one row each time you fill down, ROWS counts how many values it holds, and TAKE with a negative number keeps the last ones. Until there are enough values, the IF returns "" so the first rows stay blank instead of showing a short, misleading average.

Change E2 to 7 and the column refills: the first value appears on October 27 (49.7) and the last is 57. In Excel 2019 and earlier, which have no TAKE, use the fixed range from Method 1 and start it on the 7th row.

=IF(ROWS($B$2:B13)<E2,"",AVERAGE(TAKE($B$2:B13,-E2)))

Result: 65.333333333 shows as 65.3 with Number format

65.3, the formula as it reads in the last row (C13) with a window of 3.

Trailing or centered?

A trailing average uses the current period and the ones before it. It is what you want for dashboards and forecasts, because it only uses data you already have. The cost is lag: a 3-period trailing average runs one period behind the data, and a 7-period one runs three periods behind. In the sample, the trailing 3-day average reaches its first peak, 61, on October 24.

A centered average puts each value in the middle of its window: in C3 type =AVERAGE(B2:B4), so October 20 shows 41.7. The same peak of 61 then lands on October 23, in the middle of the three busy days it summarises. Centered averages suit looking back at past patterns, but the latest period never gets a value, because its window would need data you do not have yet.

Centering is simple for odd windows. For an even window like 12 months, the middle falls between two periods, which is why analysts average two neighbouring 12-month averages (a 2x12 average) when they need it centered.

Last 7 entries or last 7 days?

The sheet has no row for October 25. The last 7 rows therefore cover October 24 to 31, and AVERAGE(B7:B13) returns 57. If you mean the last 7 calendar days, average by date instead. Put the end date in E3 and use AVERAGEIFS with "after the end date minus 7" and "on or before the end date".

That window, October 25 to 31, holds only 6 rows, so the result is the average of 6 days: 54.5. Neither answer is wrong. Pick the one your report means and say so in the heading, for example "average per trading day, last 7 days".

For a live report, put =TODAY() in E3. To average per calendar day, counting the closed day as zero, divide a SUMIFS by 7 instead of using AVERAGEIFS.

=AVERAGEIFS(B2:B13,A2:A13,">"&E3-7,A2:A13,"<="&E3)

Result: 54.5

54.5: October 25 to 31, an average of the 6 days the shop was open.

Weighted moving average with SUMPRODUCT

A simple moving average gives every day the same weight. A weighted one counts recent days more, so it reacts faster to change. Put the weights in E4:E6 (1 for the oldest day, 3 for the newest), multiply each value by its weight with SUMPRODUCT, and divide by the total weight.

For the last three days (55, 63 and 78 orders), the sum of value times weight is 415, the weights add up to 6, and the weighted average is 69.2, against 65.3 for the simple average. It sits closer to the 78 because the newest day counts three times. Keep the weights in a column the same height as the window, and the weight cells absolute ($E$4:$E$6) when you fill the formula down.

=SUMPRODUCT(B11:B13,E4:E6)/SUM(E4:E6)

Result: 69.166666667 shows as 69.2 with Number format

69.2 for October 31, with weights 1, 2 and 3.

Blanks, zeros and a chart trendline

AVERAGE skips empty cells but counts zeros. If a day's count is missing and you leave it blank, that window averages two values instead of three. If you type 0, it drags the average down as if nobody ordered. Decide which is true, and to show nothing for incomplete windows use =IF(COUNT(B2:B4)<3,"",AVERAGE(B2:B4)).

If you only need to see the trend on a chart, Excel can draw the moving average for you.

  1. Make a line chart of the dates and orders.
  2. Click the line, then the + button next to the chart, and point to Trendline > More Options.
  3. In the Format Trendline pane, choose Moving Average and set Period to 3 or 7.

Common mistakes

Dollar signs on both ends of the range

=AVERAGE($B$2:$B$4) repeats the same number on every row. Keep both ends relative so the window moves.

Starting the formula in the first row

The first rows do not have a full window. Start on row N, or use the IF and ROWS version that stays blank until the window is full.

Missing dates treated as if they were there

"Last 7 rows" and "last 7 days" differ when days are missing. Use AVERAGEIFS on the date column for calendar windows.

Comparing averages with different windows

A 7-day average is smoother and lags more than a 3-day one. Keep the window in a labelled input cell and use the same one across reports.

FAQ

How do I calculate a 7-day moving average in Excel?

Type =AVERAGE(B2:B8) next to the 7th day and fill it down. If some dates are missing and you mean calendar days, use =AVERAGEIFS(B:B,A:A,">"&A8-7,A:A,"<="&A8) instead.

How do I calculate a 12-month moving average?

With monthly data in B2 down, put =AVERAGE(B2:B13) next to the 12th month and fill it down. Each row then averages that month and the 11 before it, which removes seasonal swings.

What is the difference between a moving average and a running average?

A moving average uses a fixed window that slides, such as the last 3 rows. A running (cumulative) average uses every value from the start, =AVERAGE($B$2:B2) filled down.

Can Excel calculate a moving average without formulas?

Yes, for charts. Add a trendline to a line chart and pick Moving Average with a period. The values are drawn on the chart but not written into cells.

Should I use a simple or weighted moving average?

Simple is easier to explain and fine for most reports. Weighted reacts faster to recent changes, which helps when the latest days matter most. Write the weights in cells so readers can see and change them.

Functions used

Related guides

Updated