Short answer: a rolling 12-month total adds up the 12 months ending at the current date: CALCULATE ( [Revenue], DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -12, MONTH ) ). Every point covers a full year, so seasonality disappears and the trend shows. A moving average divides by the number of periods: AVERAGEX over the months in the same window. On a single visual, the visual calculation MOVINGAVERAGE ( [Revenue], 3 ) is the shortcut.
Monthly revenue goes up and down with the seasons, and comparing December with November says little. The rolling 12-month line goes up when the business grows and down when it shrinks, whatever the season.
What does a rolling total show?
- Monthly
- Rolling 12 months
The monthly columns swing from 80 to 190; the rolling line climbs steadily, which is the real story: every month beat the same month last year by about 9%, and the December point (1,395) is the whole year's total.
Which measures do you need?
Revenue R12M =
CALCULATE (
[Revenue],
DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -12, MONTH )
)
-- the same a year earlier, for growth of the rolling total
Revenue R12M LY = CALCULATE ( [Revenue R12M], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
R12M Growth % = DIVIDE ( [Revenue R12M] - [Revenue R12M LY], [Revenue R12M LY] )
-- 3-month moving average of monthly revenue
Revenue 3M Avg =
AVERAGEX (
DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH ),
[Revenue]
)Careful with the last one: AVERAGEX over DATESINPERIOD iterates days, so it averages daily revenue. For a monthly average, iterate months:
Revenue 3M Avg =
CALCULATE (
AVERAGEX ( VALUES ( 'Date'[Year Month] ), [Revenue] ),
DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH )
)DATESINPERIOD ( dates, start, number, interval ) returns the dates from start going back (negative) or forward (positive) by that many intervals: DAY, MONTH, QUARTER, YEAR (and WEEK with a calendar).
How do you show only full windows?
At the start of the data, the first 11 points have less than 12 months behind them and look too low. Return BLANK until a full window exists:
Revenue R12M Full =
VAR FirstSale = CALCULATE ( MIN ( Sales[Order Date] ), REMOVEFILTERS ( 'Date' ) )
VAR WindowStart = EDATE ( MAX ( 'Date'[Date] ), -12 ) + 1
RETURN
IF ( WindowStart >= FirstSale, [Revenue R12M] )Also stop the line at the last date with data, as for YTD, or it stays flat into the future while the window empties.
What is the visual calculation shortcut?
On a line chart by month, add a visual calculation:
Moving average = MOVINGAVERAGE ( [Revenue], 3 )It averages each month with the two before it, on the months the visual shows, with no date table logic. At the first two months the window is shorter, so check the start of the line. It is limited to that visual; see visual calculations.
What goes wrong?
- Averaging days instead of months.
AVERAGEX ( DATESINPERIOD ( ... ) )iterates dates. - MAX of the fact date.
MAX ( Sales[Order Date] )ignores months without sales; use the date table. - Partial windows at the start. Blank them.
- A rolling total by year on the axis. At year level, the window ends on 31 December and equals the year total; rolling totals belong on monthly or daily axes.
Where can you check this?
- Microsoft Learn: DATESINPERIOD function (DAX)
- Microsoft Learn: MOVINGAVERAGE function (DAX)
- Microsoft Learn: EDATE function (DAX)
Where do you start?
Add Revenue R12M as a line on your monthly revenue chart and blank the partial windows. Year over year compares the rolling total with last year.