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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Jo_Swinnen
Frequent Visitor

Rolling 6 months with a variable number of months on the x-axis

Hi,

 

I've created several measures in my report to make visualisations with a variable number of months on the x-axis by using a numeric parameter 'number of months'.

For instance: 

Total= CALCULATE(sum([Revenue]),DATESINPERIOD('Dim Date'[Date],MAX('Dim Date'[Date]),-[Number of months],MONTH))
 
By placing a slicer on the month_year in Dim date and a slicer with the numeric parameter and on the x axis I placed a month_year column out of the fact table, the number of months are variable. 
But now I want the rolling 12 months also in this visualisation. 
But I get the same results as the total measure. 
 
I tried two measures:
Total 12 months = CALCULATE([Total], DATESINPERIOD('Dim Date'[Date],max('Dim Date'[Date]),-12,MONTH))
Total 12 months = CALCULATE(CALCULATE([Total],DATESINPERIOD('Dim Date'[Date],max('Dim Date'[Date]),-12,MONTH), DATESINPERIOD('Dim Date'[Date],MAX('Dim Date'[Date]),-[Number of months],MONTH))
 
Can anyone help?
 
Kind regards,
 
Jo 
1 REPLY 1
Anonymous
Not applicable

Hi @Jo_Swinnen ,

You can use the SAMEPERIODLASTYEAR function to calculate the rolling 12 months based on the same period of the previous year. 

Total 12 months = CALCULATE([Total], SAMEPERIODLASTYEAR(‘Dim Date’[Date]))

 

You can use the PARALLELPERIOD function to calculate the rolling 12 months based on a specified number of intervals in the past or future.

Total 12 months = CALCULATE([Total], PARALLELPERIOD(‘Dim Date’[Date], -12, MONTH))

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

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

 

 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.