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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
AndrewEllison
Frequent Visitor

Rolling 24 Month Line Chart Comparison

Hi All,

 

Looking for some help on the following.

 

I currently have a line chart build to show previous 24 months based on a slicer selection:

 

Rolling 24 = 

VAR CurrentDate = MAX('Date'.[Date])
VAR PreviousDate = DATE(Year(CurrentDate),MONTH(CurrentDate)-24,DAY(CurrentDate)

VAR Results = 

CALCULATE(

      SUM([Debit])

      FILTER(

                  Metric_Date,

                  Metridc_Date[Date]>=PreviousDate && Metric_Date[Date] <= CurrentDate

)

)

RETURN

Results

 

What I'd like to do is rather than showing that time period as a rolling 24 months, break it into most recent 12 months and compare it to the previous 12 months. So March 21 compares to March 20, Feb 21 to Feb 20 and so on. So far I haven't had any luck in determining how to show....any help would be appreciated.

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @AndrewEllison ,

 

You could create a calendar table;

Then create a measure as below:

 

Value in last 12 month = CALCULATE(SUM('Table'[Current Value]),DATEADD('calendar table'[Date],-12,MONTH))

 

And you will see:

v-kelly-msft_0-1615457361016.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @AndrewEllison ,

 

You could create a calendar table;

Then create a measure as below:

 

Value in last 12 month = CALCULATE(SUM('Table'[Current Value]),DATEADD('calendar table'[Date],-12,MONTH))

 

And you will see:

v-kelly-msft_0-1615457361016.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

I recommend you create your own calendar table before trying such problems. https://exceleratorbi.com.au/power-bi-calendar-tables/

you would add a month index column (covered in the link above). You need a column that starts at 1 and increments by one for each month, never resetting. With this integer column, you can write time intelligence functions with much easier control.

 

https://exceleratorbi.com.au/dax-time-intelligence-beginners/

 

 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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