Forum Discussion
Dax for variable text by selected Value
Hello together,
i have the following filter Box:
| Number | Country |
| 1 | Germany |
| 1 | China |
| 2 | USA |
I have a filter for Country.
Now my problem:
- filter by China -> Text = "only China"
- filter by USA and Germany -> Text = "without China"
- no filter set -> "All selected"
Dax:
- Anonymous6 years ago
Hey Anonymous
Your solution is actually simpler than you think since you can just create a CONCATENATEX function to combine the selected values in the filter. See the thread below: https://community.powerbi.com/t5/Desktop/Card-visual-with-multiple-selection-slicer/td-p/678090
If you need it to say "Without China" and "All Selected" you can just stick your IF function around the CONCATENATEX instead of your DINSTINCTCOUNT function. I don't like that idea because you will need an IF statement for each scenario. If this is what you are looking for then I recommend create another table for each scenario and the ntext which you would like to display and then using a LOOKUPVALUE function to find the text you need.
If I am misunderstanding and you are looking to display the text on your filter then that is more complicated, but you can use the ideas above to create concatenated search and filter parameters. If you are trying to create a filter based on the slicer I recommend reading this thread: https://community.powerbi.com/t5/Desktop/Dynamic-Slicer-based-on-Slicer/td-p/429694
1 Reply
- AnonymousNot applicable
Hey Anonymous
Your solution is actually simpler than you think since you can just create a CONCATENATEX function to combine the selected values in the filter. See the thread below: https://community.powerbi.com/t5/Desktop/Card-visual-with-multiple-selection-slicer/td-p/678090
If you need it to say "Without China" and "All Selected" you can just stick your IF function around the CONCATENATEX instead of your DINSTINCTCOUNT function. I don't like that idea because you will need an IF statement for each scenario. If this is what you are looking for then I recommend create another table for each scenario and the ntext which you would like to display and then using a LOOKUPVALUE function to find the text you need.
If I am misunderstanding and you are looking to display the text on your filter then that is more complicated, but you can use the ideas above to create concatenated search and filter parameters. If you are trying to create a filter based on the slicer I recommend reading this thread: https://community.powerbi.com/t5/Desktop/Dynamic-Slicer-based-on-Slicer/td-p/429694