FormulaCraft

How to calculate a moving average in Excel and Google Sheets

Topic:AVERAGE & central tendency
Excel & Google Sheets
=AVERAGE(B2:B4)

Verified example

Computed by a real spreadsheet engine on the sample data below.

DayValue
110
214
312
418
516

=AVERAGE(B2:B4)12

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Decide on window size N (e.g. 3 periods).
  2. 2In the first output row where a full window exists (row N+1 if data starts at row 2), enter =AVERAGE(B2:B4) for a 3-period window.
  3. 3Copy the formula down — relative references shift automatically, giving =AVERAGE(B3:B5) in the next row, etc.
  4. 4Leave output cells blank for the first N-1 rows where a full window is not yet available.
  5. 5For a self-adjusting formula, use OFFSET: =AVERAGE(OFFSET(B4,0,0,-3,1)) copied down from the third data row.

Tips

Working on a sheet you inherited? Run the Auditor on the whole file first — it flags every #REF!, #N/A, broken column pattern, and inconsistent formula in seconds, free, no signup.

Frequently asked

Should I use AVERAGE or AVERAGEIF for a moving average?

Plain AVERAGE with a relative range is the right tool. AVERAGEIF adds conditions, which are not needed for a simple rolling window.

How do I handle the first N-1 rows where the window is incomplete?

Either leave them blank, use =IF(ROW()-ROW($B$2)+1>=N, AVERAGE(OFFSET(...)), "") to suppress early values, or accept a partial window average for early rows.

More on AVERAGE & central tendency

See all →

Formulas used

Related tasks

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: