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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.