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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.