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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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