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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Getting 12 months running total based on excels Last Twelve Months

Hey guys, I'm new to powerBI and I can't figure out the solution to my problem. The probem is the Line chart X axis that is MonthYear is showing the separate amounts of each month, instead of the total. What I want to do is like this in excel.Excel LTM total displayed over 12 monthsExcel LTM total displayed over 12 months

The excel above is always showing the total of last 12 months. So the total in January 2020 was like this over 12 months, and we see the total of the last 12 months from December was a little less, and so on.

 

2020-02-26 15_14_10-Month End Report for Peter - Power BI Desktop.png

Right now I want to show the total that is in the card at the Jan-2020, and below I am showing the total from December 2019 which is a little less. And I want to display this in the X axis line chart, just like in excel.

2020-02-26 15_14_27-Month End Report for Peter - Power BI Desktop.png

The measure I am using to get the 12 months sum is this:

Sales last N months = CALCULATE(SUM(InvoiceLines[SellPriceExclVAT]), DATESINPERIOD('Date'[Date], MAX('Date'[Date]), - 12, MONTH))
 
My problem is, instead of showing the total for that selected month in the line chart, it is splitting the sales into 12 months that create that 12 months back total. Any help would be really appreciated!
 
PROBLEM SOLVED! 
 
It is possible to solve this total calculation with the measure I have created with a relative date slicer.
The problem was I was using the invoiceDate from the fact table, not the actual date dimension. 
I took the Date attribute from the Date dimension and used it as a relative date slicer and everything works perfectly!
 
 
 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

You can use a relative date filter for that

https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range

 

Or do the same in visual level filter

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

You can use a relative date filter for that

https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range

 

Or do the same in visual level filter

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Or try one of the three

 12 month =
 CALCULATE(SUM('Monthly Collection Report PBI'[Debit credit value])
	, DATESBETWEEN('Date'[Date], Min(dateadd('Date'[Date],-12,month)), MAX('Date'[Date])))
 
 12 month =
 
 var _min = Minx(allselected('Date'),dateadd('Date'[Date],-12,month))
 var _max = Minx(allselected('Date'),'Date'[Date])
 
  CALCULATE(SUM('Monthly Collection Report PBI'[Debit credit value])
	, DATESBETWEEN('Date'[Date],_min , _max))
	
	
12 month =
 
 var _min = Minx(allselected('Date'),dateadd('Date'[Date],-12,month))
 var _max = Minx(allselected('Date'),'Date'[Date])
 
  CALCULATE(SUM('Monthly Collection Report PBI'[Debit credit value])
	, filter(all('Date'),'Date'[Date]>=_min && 'Date'[Date]<= _max))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

Sadly relative slicer and these measures did not produce the result I need. I keep getting the same thing.

The line showing separate values through the months that add up to the total, instead of showing 12 totals

Can you share sample data and sample output.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

https://drive.google.com/open?id=1h4ewmgy2oVf24c45GPEGKH58agIyZp0m

 

Attached a pbix file with dummy data I tried to replicate. Try clicking through the months from january 2020 till may 2019 or something like that and watch how the total is displayed in the line. What I want is that when you click on jan 2020 slicer, it will display the total, but also display the total for the rest of the 12 months in the X Axis. So the end result should be a line displaying all 12 total months back, depending on which month you select in the slicer.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors