Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi everyone,
I am new to Power BI and exploring the dashboard. I have created a measure to calculate the cumulative value.
Cumulative Freezer=
CALCULATE (
SUM ( 'Business Plan'[Freezer] ),
FILTER (
ALL ( 'Business Plan'[Period] ),
'Business Plan'[Period] <= MAX ( 'Business Plan'[Period] )
)
)
However, I want to make the chart more dynamic, like through a parameter selection I will get different cumulative value from different column.
But it seems that DAX doesn't have a function like "colnames" which allow me to pass dynamtic column to SUM function.
Can anyone help me with it? Thank you very much.
Solved! Go to Solution.
@Anonymous wrote:
Thanks for the disconnected slicer information. But I think the main difference is that I hope to filter by columns but the disconnected slicer filters data by rows. Still thanks for your information.
@Anonymous
In my opinion, a better practice for your case is to unpivot the columns and slice the unpivoted column.
If the way in your original post is still preferable, you could try to create measure as
Cumulative Freezer = SWITCH ( TRUE (), HASONEVALUE ( ParameterTable[Parameter] ) && ISFILTERED ( ParameterTable[Parameter] ) && LASTNONBLANK ( ParameterTable[Parameter], "" ) = "Freezer", CALCULATE ( SUM ( 'Business Plan'[Freezer] ), FILTER ( ALL ( 'Business Plan'[Period] ), 'Business Plan'[Period] <= MAX ( 'Business Plan'[Period] ) ) ), HASONEVALUE ( ParameterTable[Parameter] ) && ISFILTERED ( ParameterTable[Parameter] ) && LASTNONBLANK ( ParameterTable[Parameter], "" ) = "Washing machine", CALCULATE ( SUM ( 'Business Plan'[Washing machine] ), FILTER ( ALL ( 'Business Plan'[Period] ), 'Business Plan'[Period] <= MAX ( 'Business Plan'[Period] ) ) ), 0 )
Hi @Anonymous
You cannot pass a column name into a DAX measure as far as I am aware.
You can pass values within a column to a DAX measure though.
Do you have an example of what you are trying to achieve?
Here is a sample of my data. So far I created a measure for column "Freezer".
Cumulative Freezer=
CALCULATE (
SUM ( 'Business Plan'[Freezer] ),
FILTER (
ALL ( 'Business Plan'[Period] ),
'Business Plan'[Period] <= MAX ( 'Business Plan'[Period] )
)
)
I hope that I can have different measure for different columns using parameter or other method so that I do not need to create new measure for every single column. A sample chart is below:
Hi @Anonymous
It appears that you could use the disconnected slicers option in which you might have to create a few measures, but for the end user they can click on a slicer and it will change dynamically for them?
Thanks for the disconnected slicer information. But I think the main difference is that I hope to filter by columns but the disconnected slicer filters data by rows. Still thanks for your information.
@Anonymous wrote:
Thanks for the disconnected slicer information. But I think the main difference is that I hope to filter by columns but the disconnected slicer filters data by rows. Still thanks for your information.
@Anonymous
In my opinion, a better practice for your case is to unpivot the columns and slice the unpivoted column.
If the way in your original post is still preferable, you could try to create measure as
Cumulative Freezer = SWITCH ( TRUE (), HASONEVALUE ( ParameterTable[Parameter] ) && ISFILTERED ( ParameterTable[Parameter] ) && LASTNONBLANK ( ParameterTable[Parameter], "" ) = "Freezer", CALCULATE ( SUM ( 'Business Plan'[Freezer] ), FILTER ( ALL ( 'Business Plan'[Period] ), 'Business Plan'[Period] <= MAX ( 'Business Plan'[Period] ) ) ), HASONEVALUE ( ParameterTable[Parameter] ) && ISFILTERED ( ParameterTable[Parameter] ) && LASTNONBLANK ( ParameterTable[Parameter], "" ) = "Washing machine", CALCULATE ( SUM ( 'Business Plan'[Washing machine] ), FILTER ( ALL ( 'Business Plan'[Period] ), 'Business Plan'[Period] <= MAX ( 'Business Plan'[Period] ) ) ), 0 )
Thank you! I think unpivot columns are suitable for my case and thank you for the code I will also try!
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
93 | |
85 | |
84 | |
73 | |
49 |
User | Count |
---|---|
142 | |
133 | |
110 | |
68 | |
55 |