Using calculation groups to selectively replace measures in DAX expressions
Video: https://www.youtube.com/watch?v=xS1t25_GsWw
Article and Video: https://www.sqlbi.com/articles/using-calculation-groups-to-selectively-replace-measures-in-dax-expressions/
"Calculation groups replace measure references with the DAX expression of the calculation item that is active in the filter context."
Shows the "pattern" for injecting any parameter from the report inside a measure as the following steps:
- Rename calculation group as "Internal..." and hide it
- Create disconnected table which is a copy of the Internal calculation group
- Use disconnected table in slicer to allow user to choose the calculation desired
- Create "Internal" measure
- Use CALCULATE to apply calculation item based on user selection
Copy disconnected table:
PriceToUse =SELECTCOLUMNS ( InternalPriceToUse, "PriceToUse", InternalPriceToUse[InternalPriceToUse], "Ordinal", InternalPriceToUse[Ordinal])
Internal Sales Amount :=SUMX ( Sales, Sales[Quantity] * Sales[Net Price]) SalesAmount :=CALCULATE ( [Internal Sales Amount], TREATAS ( VALUES ( PriceToUse[PriceToUse] ), InternalPriceToUse[InternalPriceToUse] ))
Comments
Post a Comment