Skip to main content

Power BI

New

On visuals, adapt the name of measure according to a slicer selection

Vote (2) Share
Elisa Terzo's profile image

Elisa Terzo on 10 Aug 2020 14:33:50

Example: have a measure that executes different calculation according to a slicer selection.
Actual behavior: using the measure on visual, the name is static.
Desired behavior: change the name shown in visuals according to the slicer selection. For example: like titles or concatenating the selected value at the end of measure name.

Comments (1)
Elisa Terzo's profile image Profile Picture

5dbfcfc3 c6d1-ea11-a812-000d3a9b112e on 10 Aug 2020 19:57:18

RE: On visuals, adapt the name of measure according to a slicer selection

This is pretty much already available using the SELECTEDVALUE() DAX function.
Do this: Create a table (MyTable) with columns ID (Integer) and Name (text). Enter values:
1 / SUM of some Measure
2 / AVG of the Measure

Create two measures that would return each of the above calculations.

Create a Measure with the following formula:
My Measure = SWITCH(
SELECTEDVALUE ( 'MyTable'[ID]),
1, [Sum of some Measure],
2, [AVG of the Measure]
)

Add this third measure to a chart of table. On the same page, add a Slicer for MyTable. When you select one value of another, the SWITCH statement looks at the SELECTEDVALUE of that table/slicer, and returns the appropriate Measure.