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

Clustered column chart with cumulative sum measure based on filters applied on chart

Dear all,

 

I am quite new on Power BI and have been struggling a lot to fix the below issue. I have spent hours and still cannot find a solution. Maybe is it my database that is not suitable for that?

 

The issue: I have a database loaded into PBI and the database has the below format. I would like to create a clustered bar chart including a measure that is the running total of the selected indicators (line and clustered bar chart). In this case, I am interested by the Financial Indicator "NCF", in a "Poor Economy" and "Good Economy" scenario for the years 2023 and 2024. I would like the chart to show a running total for these two scenario see line on chart below.

 

The issue is the following. when I apply the running total DAX formula I have created, it does compute the running total of both the "Poor Economy" and "Good Economy" together. In other terms, my measure does not split the calculation by the Economic scenario and assumes it is a single scenario. I therefore end up with a single running total line which is wrong.

 

My DAX formula is the following: 

 
CumulativeTotal = CALCULATE(
     SUM(TableQuery[Value]),
     'Calendar'[Date] <= MAX('Calendar'[Date])
)
 
Does someone has an idea on how to make the running total formula filter for many column? (in this case, filter the financial indicator for NCF, economic scenario for "good" and "poor", and years for 2023 and 2024)? I obviously have thousands of data on 50+ years and 30+ financial indicators. Therefore, I think that any DAX formula including filters within brackets (e.g. filter "NCF") are not going to work as my database is big and I can add/remove some indicators from time to time
 
Thanks a LOT in advance for the help, this goes beyond my current knowledge. I can add some details if needed just let me know

 

PBI.PNG

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

To create a running total for a specific financial indicator, economic scenario, and years, you can use the following DAX formula:

CumulativeTotal = 
CALCULATE(
    SUM(TableQuery[Value]),
    FILTER(
        ALL(TableQuery),
        TableQuery[Financial Indicator] = "NCF" &&
        TableQuery[Economic Scenario] IN {"Poor Economy", "Good Economy"} &&
        TableQuery[Date] IN {DATE(2023,1,1), DATE(2024,1,1)} &&
        TableQuery[Plant Name] = SELECTEDVALUE(TableQuery[Plant Name])
    ),
    'Calendar'[Date] <= MAX('Calendar'[Date])
)

This formula uses the FILTER function to apply multiple filters to the table, including the financial indicator, economic scenario, years, and plant name. The SELECTEDVALUE function is used to ensure that the plant name filter is applied correctly.

You can then use this measure in your clustered bar chart to show the running total for the selected indicators. 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

Anonymous
Not applicable

Sorry for that did not know we could add a table, here you go and thanks a lot in advance 🙂

 

Let me know if something more is missing and I'll add it!

 

 

Financial IndicatorEconomic ScenarioDatePlant NameValue
NCFPoor Economy31/12/2023Plant 110
NCFPoor Economy31/12/2024Plant 115
NCFGood Economy31/12/2023Plant 120
NCFGood Economy31/12/2024Plant 125
NCFPoor Economy31/12/2023Plant 2100
NCFPoor Economy31/12/2024Plant 2110
NCFGood Economy31/12/2023Plant 2120
NCFGood Economy31/12/2024Plant 2130
CostsPoor Economy31/12/2023Plant 11
CostsPoor Economy31/12/2024Plant 13
CostsGood Economy31/12/2023Plant 25
CostsGood Economy31/12/2024Plant 27

Hi @Anonymous ,

 

To create a running total for a specific financial indicator, economic scenario, and years, you can use the following DAX formula:

CumulativeTotal = 
CALCULATE(
    SUM(TableQuery[Value]),
    FILTER(
        ALL(TableQuery),
        TableQuery[Financial Indicator] = "NCF" &&
        TableQuery[Economic Scenario] IN {"Poor Economy", "Good Economy"} &&
        TableQuery[Date] IN {DATE(2023,1,1), DATE(2024,1,1)} &&
        TableQuery[Plant Name] = SELECTEDVALUE(TableQuery[Plant Name])
    ),
    'Calendar'[Date] <= MAX('Calendar'[Date])
)

This formula uses the FILTER function to apply multiple filters to the table, including the financial indicator, economic scenario, years, and plant name. The SELECTEDVALUE function is used to ensure that the plant name filter is applied correctly.

You can then use this measure in your clustered bar chart to show the running total for the selected indicators. 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

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