Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi all,
I have a filter on my report with colors:
Colors:
Blue
Red
Purple
Yellow
Grey
Black
Now I want to create a dynamic label which only focusses on the color "Blue". So if the color Blue is selected (individually or in all selected) I want the card to display: "Blue included" and if the color Blue is deselected and want it to show "Blue excluded"
Does anyone has a smart way to do this in Dax?
Many thanks!
Solved! Go to Solution.
Hi @Anonymous ,
Try this measure
Measure =
IF (
NOT ( ISFILTERED ( 'Table'[Colors] ) ),
"Blue excluded",
IF (
"Blue" IN ALLSELECTED ( 'Table'[Colors] ),
"Blue included",
"Blue excluded"
)
)
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.
Hi @Anonymous ,
Try this measure
Measure =
IF (
NOT ( ISFILTERED ( 'Table'[Colors] ) ),
"Blue excluded",
IF (
"Blue" IN ALLSELECTED ( 'Table'[Colors] ),
"Blue included",
"Blue excluded"
)
)
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.
HI @Anonymous ,
I am assuming that the COLOR is a column in your dataset as you haven't provided any details on that.
This can be done by creation a measure calculation for the label:
labelCalc =
var val1 = SELECTEDVALUE(tablename[color])
RETURN
SWITCH
(
TRUE(),
val1 = "Blue", "Blue included", "Blue excluded"
)
Replace tablename[color] in the above DAX with your tablename and column name.
Thanks,
Pragati
Hi Pragati,
Thanks for your help!
Just one remaining question: if there is no selection made in the filter (so all colors included) the label does not show "Blue included", do you have a way to do this?
Many thanks!
HI @Anonymous ,
Yes you can modify your DAX as follows to handle that scenario:
labelCalc =
var val1 = SELECTEDVALUE(tablename[color])
RETURN
SWITCH
(
TRUE(),
val1 = "Blue", "Blue included",
val1 != "Blue", "Blue excluded", "Blue included"
)
See if the above modified DAX works.
Thanks,
Pragati
User | Count |
---|---|
98 | |
90 | |
77 | |
71 | |
64 |
User | Count |
---|---|
114 | |
97 | |
95 | |
68 | |
65 |