Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
I need a KPI for management that shows rolling 12 month sales based on the last visible date in the report. Along with that, I also need the year over year percent change for the same rolling 12 month window. I have a proper date table and a Total Sales measure, but I am not sure how to structure the DAX to handle the rolling window and the YoY comparison. What is the right way to write these measures so they work at any date granularity?
Solved! Go to Solution.
Hi @Yuziu8o ,
you can write measures as follow:
rolling_month := calculate(sum(sales), filter (all(table) , date >= EDATE (max(date) , -12)))
YOY := divide ( calculate(sum(sales), filter (all(table) , date >= EDATE(EDATE (max(date) , -12),-12) && date < EDATE(max(date), -12))) , calculate(sum(sales), filter (table , date >= EDATE (max(date) , -12))))
If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution ✔️ to help the other members find it more quickly.
You can build a rolling 12 month KPI with three measures. Each one anchors to the last visible date in the current filter context, so it works at any granularity.
Rolling 12 Month Sales
Rolling 12 Month Sales YoY
Rolling 12 Month YoY Percent Change
This gives a clean rolling 12 month value and a year over year comparison using the same window.
You can build a rolling 12 month KPI with three measures. Each one anchors to the last visible date in the current filter context, so it works at any granularity.
Rolling 12 Month Sales
Rolling 12 Month Sales YoY
Rolling 12 Month YoY Percent Change
This gives a clean rolling 12 month value and a year over year comparison using the same window.
Hi @Yuziu8o ,
you can write measures as follow:
rolling_month := calculate(sum(sales), filter (all(table) , date >= EDATE (max(date) , -12)))
YOY := divide ( calculate(sum(sales), filter (all(table) , date >= EDATE(EDATE (max(date) , -12),-12) && date < EDATE(max(date), -12))) , calculate(sum(sales), filter (table , date >= EDATE (max(date) , -12))))
If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution ✔️ to help the other members find it more quickly.
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
Sales total: =
SUM( sales[sales] )
12 Months rolling: =
VAR _lastdate =
MAX ( sales[date] )
VAR _t =
SUMMARIZE (
FILTER (
ALL ( 'Calendar' ),
'Calendar'[Year-Month sort] <= EOMONTH ( _lastdate, 0 )
),
'Calendar'[Year-Month],
'Calendar'[Year-Month sort]
)
VAR _window =
WINDOW ( 1, ABS, 12, ABS, _t, ORDERBY ( 'Calendar'[Year-Month sort], DESC ) )
RETURN
IF ( COUNTROWS ( _window ) >= 12, CALCULATE ( [Sales total:], _window ) )
12 months rolling YoY %: =
VAR _currentrolling = [12 Months rolling:]
VAR _prevyearrolling =
CALCULATE (
[12 Months rolling:],
OFFSET (
-12,
ALL ( 'Calendar'[Year-Month], 'Calendar'[Year-Month sort] ),
ORDERBY ( 'Calendar'[Year-Month sort], ASC )
)
)
RETURN
IF (
_currentrolling,
DIVIDE ( _currentrolling - _prevyearrolling, _prevyearrolling )
)
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 10 | |
| 7 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 19 | |
| 14 | |
| 11 | |
| 8 | |
| 7 |