Forum Discussion
How to write a DAX function when a Slicer value is selected/included?
- 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:
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.
Note that this method breaks if you have two rows in the slicer table that contain the same text, e.g.
"Sales"
and "Sales (adjusted)". When "Sales (adjusted)" is selected in the slicer, the code with think that the "Sales" option was selected, when it wasn't.
Result = IF(CONTAINSSTRINGEXACT(CONCATENATEX(ALLSELECTED('Table'), 'Table'[project_status], ""), "Sales") = TRUE(), "A", "B")The COUNTROWS method that PaulDBrown posted might be more robust.