Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Rolling 12 months against another rolling 12 months from a previous period

Hi all - I'd like to do some DAX to get a rolling 12 month figure, then compare that to a rolling 12 month from 2 years ago, but I'm having trouble figuring out how to do it

I have a calendar table with things like 'DATE', 'YEAR', 'MONTH', 'WEEK IN YEAR NUMBER' etc and I'd like to be able to do it for the latest full completed week, so looking back from week 45 in 2021 to week 46 in 2020 and then have the same thing for from week 45 in 2019 to week 46 in 2018 and then a sum that compares the change between the 2 results

 
I'm guessing I might need some kind of variables? If anyone has any suggestions I'd be very grateful 🙂
 
For info I have a DAX measure for Product Net Sales already to get the data for 'equal to or less than week 45 from 2021', looks like this:
 
2021 ROLLING 12 MONTH PNS = CALCULATE(
SUM('Invoice_Transactions'[Product Net Sales]),
FILTER('Calendar','Calendar'[WEEK IN YEAR NUMBER] <= 45))
1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, heres my solution.

vkalyjmsft_0-1637545176795.png

 

vkalyjmsft_1-1637545176799.png

 

vkalyjmsft_2-1637545176804.png

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, heres my solution.

vkalyjmsft_0-1637545176795.png

 

vkalyjmsft_1-1637545176799.png

 

vkalyjmsft_2-1637545176804.png

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , You need to try measure like

 

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))

 


Rolling 12 before 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAXX('Date',dateadd('Date'[Date],-12,month)),-12,MONTH))

 

 

For week level with rank you can get similar results

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.