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
monge
Regular Visitor

Comparing running totals of different periods in the same line chart

I'm trying to compare running totals of different periods that are user defined through date slicers. The fact table is rather simple, a date column with the selling date and another column with the selling value. Something like this:

WhatsApp Image 2024-04-03 at 09.36.46.jpeg

There are other tables in the model and all dates are linked to a calendar table. What I'm trying to do is to create two running totals of the "Value" column where the time periods for it are user defined through date slicers, and then use these two measures in the same line chart, even though the time periods might be different. I know I can create the running total using a measure like this

 

 

CUMSUM = CALCULATE(
               SUM('FACT TABLE'[Value]),
               FILTER(ALLSELECTED(Calendar), Calendar[Date] <= MAX(Calendar[Date])
              )

 

 

 But I'm not sure how to merge together two measures in the same line chart due to the different chosen periods. So, what I want is:

  • Create the running total CUMSUM1 of the "Value" column, where the time period for the calculation is defined by date slicer 1;
  • Create the running total CUMSUM2 of the "Value" column, where the time period for the calculation is defined by date slicer 2;
  • Merge then together in the same line chart even though the time periods are different.

I appreciate any help with this!
Thank you!

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

Hi, @monge 

 

Based on your description, I have created some measures to achieve the effect you are looking for. Following picture shows the effect of the display.

vyaningymsft_0-1712195439161.pngvyaningymsft_1-1712195460120.png

 

Measure:

SumValue =
CALCULATE (
MAX ( 'Fact Table'[value] ),
FILTER (
'Fact Table',
'Fact Table'[date]
IN ALLSELECTED ( 'Date 1'[date 1] )
|| SELECTEDVALUE ( 'Fact Table'[date] ) IN ALLSELECTED ( 'Date 2'[date 2] )
)
)


Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

I cannot visualise that line chart.  If 2 non overlapping line time periods are selected, then what should appear on the X-axis?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yaningy-msft
Community Support
Community Support

Hi, @monge 

 

Based on your description, I have created some measures to achieve the effect you are looking for. Following picture shows the effect of the display.

vyaningymsft_0-1712195439161.pngvyaningymsft_1-1712195460120.png

 

Measure:

SumValue =
CALCULATE (
MAX ( 'Fact Table'[value] ),
FILTER (
'Fact Table',
'Fact Table'[date]
IN ALLSELECTED ( 'Date 1'[date 1] )
|| SELECTEDVALUE ( 'Fact Table'[date] ) IN ALLSELECTED ( 'Date 2'[date 2] )
)
)


Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

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!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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