Rolling Averages with DATESINPERIOD
Part of the Power BI Roadmap
In short
Monthly sales jump around with festivals and holidays. A rolling 3-month average smooths the zig-zag so you can see whether the business is actually growing.
DATESINPERIOD returns a set of dates going back a chosen period from a date, which lets you build rolling 3-month or 12-month totals and averages.

Think of it like this
The cricket run rate
A batter scores 4, then 0, then 12. Judge them on one over and you'll panic or celebrate for no reason. Commentators quote the run rate over the last few overs instead. A rolling average is that run rate: always the latest few months, sliding forward each month.
Watch it happen
3-month rolling window (₹ lakh)
1/4For June, DATESINPERIOD goes back 3 months from 30 June: April, May, June. Average = 10.3.
The big ideas
What you need to know
DATESINPERIOD
DATESINPERIOD ( 'Date'[Date], end date, -3, MONTH ) returns every date in the 3 months ending on that date.
End at MAX date
Use MAX ( 'Date'[Date] ) as the end, so a month row ends on that month's last day.
Total vs average
The rolling total sums the window. For a monthly average, average the monthly totals inside the window.
Early months
The first two months don't have three months of history. Blank them so the line doesn't start misleadingly low.
See it in code
Walk through the code
1Sales Rolling 3M =2CALCULATE (3 [Total Sales],4 DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH )5)6 7Sales 3M Avg =8VAR Period =9 DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH )10VAR MonthsWithSales =11 CALCULATE (12 COUNTROWS ( FILTER ( VALUES ( 'Date'[Month Start] ), [Total Sales] > 0 ) ),13 Period14 )15RETURN16 IF (17 MonthsWithSales = 3,18 CALCULATE ( AVERAGEX ( VALUES ( 'Date'[Month Start] ), [Total Sales] ), Period )19 )1/4Sum of sales over the three months ending on the last visible date.
A rolling 3-month total and a 3-month average that stays blank until three months of history exist.
Save yourself the pain
Common mistakes
Oops
Using TODAY () as the end date.
Do this instead
Use MAX ( 'Date'[Date] ) so each month row gets its own window. TODAY () gives every row the same window.
Oops
Calling the rolling total an average.
Do this instead
Divide by the number of months, or average the monthly totals with AVERAGEX over months in the window.
Your mission
Smooth the zig-zag
Quick check
On the row for September 2026, what does DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH ) return?
Go deeper
- 1Create a rolling 3-month sales total.
- 2Turn it into a rolling average by dividing by the number of months.
- 3Plot it against monthly sales to see how it smooths the line.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.