Rolling 3-month total with DATESINPERIOD
Add up the last three months of sales for every month in your report with CALCULATE and DATESINPERIOD, a trailing total that smooths out one-off spikes.
You will learn to
- Build a trailing window of dates with DATESINPERIOD
- Anchor the window on the last visible date with MAX
- Tell a rolling total apart from a quarter-to-date total
How it works
A **rolling total** adds up a fixed-length window that ends at the period you are looking at. “Rolling 3 months” in March means January + February + March; in April it means February to April. The window slides forward one month at a time, so a single big or quiet month doesn’t dominate the line.
`DATESINPERIOD(dates, end, count, interval)` builds that window. It takes the date column, the day to count back from, how many intervals to go (negative goes back in time) and the interval: `DAY`, `MONTH`, `QUARTER` or `YEAR`. It returns a table of dates, so it goes inside `CALCULATE` as a filter.
The end point should be the **last visible date**, `MAX('Date'[Date])`. In a month row that is the month end; in a year row it is 31 December, so the year shows its last three months. DATESINPERIOD ignores the row’s own dates and builds the window from the whole Date table, which is exactly why it can reach back into earlier months.
Practice it hands-on with a real data model and a live report that updates as you type.
Quantity Last 30 Days = CALCULATE([Total Quantity], DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -30, DAY))