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
Anonymous
Not applicable

DAX Measure Running Total by Category - Two Separated Lines on Cluster Chart

Hi all,

 

I am struggling with the following issue: I try to add a running total (cumulative sum) line splitted by two different categories see screenshot below. I would like to create a measure that shows the cumulative sum of the "Good Economy" scenario and another one line showing separately the cumulative sum of the "Poor Economy" scenario. My database is only one master file as follow: 

 

Only requirement: I may add some other economic scenarios and/or financial indicators into my table so the measure should adapt to any update. Is someone able to help on this? I have been struggling a lot. As you can see on the screenshot, the running total (orange and blue lines) shown are wrong. I would like something similar to what I added on the charts manually (#1 and #2 lines)

 

Thanks a lot for that!

 

DAX measure "Running Total in Year"

Value running total in Year =
CALCULATE(
SUM('Table1'[Value]),
FILTER(
ALLSELECTED('Table1'[Date].[Year]),
ISONORAFTER('Table1'[Date].[Year], MAX('Table1'[Date].[Year]), DESC)
)
)

 

 

 

 

 

and in Economic Scenario

Value running total in Economic Scenario =
CALCULATE(
SUM('Table1'[Value]),
FILTER(
ALLSELECTED('Table1'[Economic Scenario]),
ISONORAFTER('Table1'[Economic Scenario], MAX('Table1'[Economic Scenario]), DESC)
)
)

 

Database

Financial Indicator

Economic Scenario

Date

Plant Name

Value

NCF

Poor Economy

31/12/2023

Plant 1

10

NCF

Poor Economy

31/12/2024

Plant 1

15

NCF

Good Economy

31/12/2023

Plant 1

20

NCF

Good Economy

31/12/2024

Plant 1

25

NCF

Poor Economy

31/12/2023

Plant 2

100

NCF

Poor Economy

31/12/2024

Plant 2

110

NCF

Good Economy

31/12/2023

Plant 2

120

NCF

Good Economy

31/12/2024

Plant 2

130

Costs

Poor Economy

31/12/2023

Plant 1

1

Costs

Poor Economy

31/12/2024

Plant 1

3

Costs

Good Economy

31/12/2023

Plant 2

5

Costs

Good Economy

31/12/2024

Plant 2

7

 

Thanks a lot 🙂

 

 

 

 

 

 0_Capture.PNG

1 ACCEPTED SOLUTION
Payeras_BI
Super User
Super User

Hi @Anonymous ,

I would create a measure per Economic Scenario like this:

RT Good Economy = 
VAR MaxDate = MAX('Date'[Date])
RETURN
CALCULATE(
    [Sum of value], 
    'Date'[Date] <=MaxDate,
    Table1[Economic Scenario] = "Good Economy"
)
------------------------------------------------
RT Poor Economy = 
VAR MaxDate = MAX('Date'[Date])
RETURN
CALCULATE(
    [Sum of value], 
    'Date'[Date] <=MaxDate,
    Table1[Economic Scenario] = "Poor Economy"
    )

 

Payeras_BI_0-1686218183380.png

Regards,

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

View solution in original post

1 REPLY 1
Payeras_BI
Super User
Super User

Hi @Anonymous ,

I would create a measure per Economic Scenario like this:

RT Good Economy = 
VAR MaxDate = MAX('Date'[Date])
RETURN
CALCULATE(
    [Sum of value], 
    'Date'[Date] <=MaxDate,
    Table1[Economic Scenario] = "Good Economy"
)
------------------------------------------------
RT Poor Economy = 
VAR MaxDate = MAX('Date'[Date])
RETURN
CALCULATE(
    [Sum of value], 
    'Date'[Date] <=MaxDate,
    Table1[Economic Scenario] = "Poor Economy"
    )

 

Payeras_BI_0-1686218183380.png

Regards,

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

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.

Top Solution Authors
Top Kudoed Authors