Forum Discussion
Anonymous
6 years agoNot applicable
How to write a DAX function when a Slicer value is selected/included?
I have a Slicer, i.e. I want to write a logic DAX function using IF() like: If "Successful" is selected, then do A, otherwise do B "Successful" could be selected as a single or one of mu...
- 6 years ago
Anonymous ,
You may create a measure using dax below:
Result = IF(CONTAINSSTRINGEXACT(CONCATENATEX(ALLSELECTED('Table'), 'Table'[project_status], ""), "Successful") = TRUE(), "A", "B")Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 6 years ago
Anonymous
I see v-yuta-msft has provided a solution (I wasn't even aware of the function CONTAINSSTRINGEXACT!)
Just as an alternative, I worked on a different approach:
Git
2 years agoFrequent Visitor
Here is simpler one: it works if we have to keep a check if any option is selected, If nothing selected or selected both case need to be worked, then remove Is filtered and use if satetment.
To make sure Slicer is filtered:
Check Selection = SWITCH(ISFILTERED('Table'[Value]),
"Successfull" IN ALLSELECTED('Table'[Value]),"y","n")
When nothing selected/Something selected bot scenarios to cover:
Filtered/NotFIltered=If("Successfull" IN ALLSELECTED('Table'[Value]),"y","n")
Filtered/NotFIltered=If("Successfull" IN ALLSELECTED('Table'[Value]),"y","n")