Calculate a rolling average in Power BI: validate the DAX window and denominator
A rolling average smooths short-term variation by averaging a fixed recent window. This guide uses a Power BI date table and monthly sales measure, and explains how to validate current-period inclusion, missing months, and partial periods.
Calculate a rolling average in Power BI: validate the DAX window and denominator
A rolling average computes an average over a fixed period ending at the current point. Window length, inclusion of the current period, and missing-month treatment change the result. This example calculates a 12-month average of monthly sales.
A 12-month monthly average means averaging the total for each month, not the average of daily sales rows. Decide whether each month gets equal weight or whether days should be weighted. The example assumes classic DAX time intelligence, a continuous Date table, a unique Date[YearMonth] key, and a [Sales Amount] measure. It is illustrative and was not run on a live model.
Rolling 12-Month Avg Sales =
VAR EndDate = MAX ( 'Date'[Date] )
VAR WindowDates = DATESINPERIOD ( 'Date'[Date], EndDate, -12, MONTH )
RETURN
CALCULATE (
AVERAGEX ( VALUES ( 'Date'[YearMonth] ), COALESCE ( [Sales Amount], 0 ) ),
REMOVEFILTERS ( 'Date' ),
WindowDates
)The measure captures the last date in the current context and creates a backward-looking 12-month window including that date. REMOVEFILTERS prevents the chart's current-month filter from shrinking the window; the date window is then applied. AVERAGEX evaluates each month once. COALESCE treats a month with no sales rows as zero; use a year-month key because Jan alone can combine years.
Use zero only when no sales rows truly means zero. If data is missing or the month is incomplete, zero replacement biases the average downward. Excluding blanks may produce a denominator smaller than 12, which should be disclosed. Decide whether to include an open current month or stop at the last closed month, and display data freshness. The Date table must cover the full window. A longer window reacts more slowly to sudden changes, so keep the source metric visible and label the window.
In Power BI, check the date table and relationship, create a base measure, put YearMonth on the axis, and compare the result with the arithmetic mean of the same 12 monthly totals under identical blank and weighting rules. Inspect the first window, early periods, zero-sales months, partial months, year-end and leap-year boundaries, and product/region filters. Microsoft documents DAX MOVINGAVERAGE as visual-calculation-only; do not use it as an ordinary measure function. Feature availability can vary by version and model mode. Formula is illustrative; no execution is claimed.
Sources: Microsoft Learn, Power BI time calculations; DATESINPERIOD; Quick measures; MOVINGAVERAGE.