How to average the last N values in a growing column
✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)A rolling average of the most recent entries — last 3 months, last 7 days — that stays current as rows are added.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel (desktop) | =AVERAGE(OFFSET(A2,COUNT(A2:A1000)-3,0,3,1)) | Change both 3s for a different window. Excel 365: =AVERAGE(TAKE(FILTER(A2:A1000,A2:A1000<>""),-3)). |
| Google Sheets | =AVERAGE(OFFSET(A2,COUNT(A2:A1000)-3,0,3,1)) | Identical. |
| LibreOffice Calc | =AVERAGE(OFFSET(A2,COUNT(A2:A1000)-3,0,3,1)) | Identical; the TAKE alternative needs 25.8+. |
How it works
COUNT finds how many numbers exist (5), so OFFSET starts 5−3=2 rows below the top and grabs a 3-row window — the last three values (30, 40, 50), averaging to 40. As new rows arrive the window slides automatically. OFFSET is volatile (recalculates on every change), which is fine at this scale; the TAKE version in the notes is the calmer modern equivalent. Works with SUM or MAX in place of AVERAGE for rolling totals and peaks.
Verified, not just documented
We ran =AVERAGE(OFFSET(A2,COUNT(A2:A6)-3,0,3,1)) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 40 — 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 40 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 · OFFSET · COUNT — see full Excel, Google Sheets & LibreOffice compatibility for each.
Related recipes
- How to reference a cell on another sheet
- How to average a range of times
- How to average a range that contains errors
- How to average the top N scores (drop the lowest)
- How to calculate a moving average