← All how-to recipes

How to calculate a moving average

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Smooth out noisy daily numbers into a rolling trend — a 3-, 7-, or 30-period average that updates as you drag it down the column.

The formula

AppFormulaNotes
Excel (desktop)=AVERAGE(B2:B4)Average a fixed-size window, then drag down — the range slides with each row. For a trailing 3-period on row N, point at the current row and the two above it.
Google Sheets=AVERAGE(B2:B4)Identical. For a whole spilled column: =MAP(SEQUENCE(ROWS(B:B)),LAMBDA(i,...)) or a helper AVERAGEIFS by date window.
LibreOffice Calc=AVERAGE(B2:B4)Identical drag-down behavior.

How it works

A moving (rolling) average is just AVERAGE over a fixed-size sliding window. Put =AVERAGE(B2:B4) beside the third data point and drag down: because B2:B4 is a relative range, row 5 becomes AVERAGE(B3:B5), row 6 becomes AVERAGE(B4:B6), and so on — each result is the mean of the current value and the previous two, which is a 3-period trailing average (here (10+20+30)/3 = 20). Widen the window to B2:B8 for a 7-period, or B2:B31 for a 30-period. The first few rows have no full window, so leave them blank or start the formula once enough history exists. To key the window off dates instead of row position — a true 7-DAY average even with gaps — use AVERAGEIFS with a date-range condition. Moving averages trade responsiveness for smoothness: a longer window is steadier but lags real changes more.

Verified, not just documented

We ran =AVERAGE(B2:B4) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 20 — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 20 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.

Functions used

AVERAGE — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related recipes

Related comparisons