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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
LK1992
Frequent Visitor

How to add 2 lines for running total amount in current year and Previous Year in Line Chart?

Screen Shot 2024-02-28 at 6.37.29 PM.png

 I used 2 measures for running total this year and last year. 

Running Total MTCO2 = 
CALCULATE(
[Total MTCO2],
FILTER(
ALLSELECTED('GLTRANS'[Posting Date]),
ISONORAFTER('GLTRANS'[Posting Date], MAX('GLTRANS'[Posting Date]), DESC)
)
)
 

RunningTotalLastYear =

calculate( [Cummulative Spend], dateadd(GLTRANS[Posting Date].[Date], -1, year))

but then it does show 2 lines in 2 splited line chart. but I need to have overlapped line chart like below screenshot as of example.  Could you help how to creat measures to make line chart for running total this year and last year like below screenshots?

 
Screen Shot 2024-02-28 at 6.40.43 PM.png

 

I also tried with below another measures as well, but then it's not working neither.

Cummulative Spend = 
var __oneYearVisible = HASONEVALUE(GLTRANS[Posting Date].[Year] )
var __cummulativeSpend =
if (
__oneYearVisible,
 
CALCULATE(
[Running Total MTCO2],
DATESYTD( GLTRANS[Posting Date])
)  
)
return
    __cummulativeSpend
Cummulative Spend LY = 
var __cummulativeSpend =
CALCULATE(
[Cummulative Spend],
SAMEPERIODLASTYEAR( GLTRANS[Posting Date] )
)
return
__cummulativeSpend
2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi ! 

 

I can't open the link. Could you possibly share again?

 

Thanks!!

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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