Forum Discussion
How to Dynamically Evaluate any Measure Over a Defined Summary Table
- Anonymous1 year ago
Hi kgoth
Thank you very much lbendlin and DataInsights for your prompt reply. Allow me to share something.
For your question, here is the method I provided:
Here's some dummy data
“Table”
Total Measure = SUM('Table'[Value]) Avg Measure = AVERAGE('Table'[Value]) Count Measure = COUNTROWS('Table') Per Measure = DIVIDE(SUM('Table'[Value]), CALCULATE(SUM('Table'[Value]), ALL('Table')))Create a calculation table, using CALCULATETABLE to create a table that holds the filtering context. To add columns with measures, use ADDCOLUMNS to add the measures you want to evaluate to this table.
EvaluatedMeasuresTable = ADDCOLUMNS( CALCULATETABLE( 'Table', ALLSELECTED('Table') ), "Total", 'Table'[Total Measure], "Average", 'Table'[Avg Measure], "Count", 'Table'[Count Measure], "Percentage", 'Table'[Per Measure] )Create a new table for selecting measures.
MeasureSelector = DATATABLE( "MeasureName", STRING, { {"Total"}, {"Average"}, {"Count"}, {"Percentage"} } )Use SELECTEDVALUE to dynamically select the measures to be evaluated.
DynamicMeasure = VAR SelectedMeasure = SELECTEDVALUE('MeasureSelector'[MeasureName]) RETURN SWITCH( SelectedMeasure, "Total", 'Table'[Total Measure], "Average", 'Table'[Avg Measure], "Count", 'Table'[Count Measure], "Percentage", 'Table'[Per Measure], BLANK() )Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I need the expression defined in the measures to be evaluated
Power BI sadly doesn't support EVALUATE for this.
If this is important to you please consider voting for an existing idea or raising a new one at https://ideas.fabric.microsoft.com
I'm not trying to use EVALUATE as a DAX function, I'm just using it in this context as a verb.