Forum Discussion
Custom messages based on slicer selections
Hello,
I have the following table and i am using a slicer with a list to select the Document ID and a Card visualization to show the selected Document ID. It works when one Document ID is selected in the slicer, but i am trying to have custom text message in the same Card visualization for the following scenarios:
1. If only one Document ID is selected in the slicer list, show the Document ID number.
2. If more than one Document ID is selected (but not all), show the list of Document ID's selected.
3. If all or no Document ID are selected, show the message "All Document ID's selected".
Is this possible? Any help is much appreciated!
| Document ID | Validity | Region |
| 3998 | 01/01/2018 | HEP |
| 4050 | 01/01/2020 | HEP |
| 4050 | 18/05/2020 | HEP |
| 4060 | 11/01/2020 | HEP |
| 4139 | 12/08/2020 | WAP |
| 4145 | 01/01/2020 | WAP |
| 4149 | 01/01/2020 | HEP |
| 4157 | 25/11/2019 | HEP |
| 4160 | 01/01/2020 | HEP |
| 4160 | 08/04/2020 | HEP |
| 4164 | 01/01/2020 | WAP |
| 4166 | 01/01/2020 | HEP |
| 4187 | 01/01/2020 | HEP |
| 4187 | 07/12/2022 | HEP |
| 4187 | 17/12/2023 | HEP |
| 4187 | 19/12/2022 | HEP |
| 4248 | 10/08/2022 | WAP |
| 4314 | 01/01/2024 | HEP |
| 4474 | 01/01/2020 | WAP |
| 4481 | 01/01/2023 | WAP |
| 4487 | 01/08/2020 | WAP |
| 4495 | 01/11/2022 | WAP |
| 4685 | 01/01/2024 | WAP |
| 4688 | 01/01/2023 | WAP |
| 4691 | 01/01/2023 | WAP |
| 4813 | 10/12/2019 | WAP |
| 4832 | 01/01/2021 | WAP |
| 4997 | 01/01/2020 | HEP |
Hi Anonymous ,
Can you try this?
Filter Selected =IF (CALCULATE (HASONEVALUE ( MyTable[Document ID] ),ALLSELECTED ( MyTable ))= TRUE (),CONCATENATEX ( VALUES ( MyTable[Document ID] ) , [Document ID] , ",") ,"Multiple Document ID's selected")Thank you
7 Replies
- AUDISU
Resolver III
Hi Anonymous ,
Use following DAX with IF function.
Measure = CONCATENATEX ( VALUES ( MyTable[Document ID] ) , [Document ID] , ",")Thank you.- AnonymousNot applicable
Hi AUDISU Thank you for your reply! I have tried the measure and it works when one or multiple Document ID's are selected in the slicer list. However, when no Document ID's or "Select all" option is chosen, there is a big list of all the Document IDs. Is it possible to show a custom text message instead? Such as, "All Document ID's selected"?
I have made some progress but i do not know how to change:
1. The value "1" to the currently selected Document ID
2. The value "2" to a text that says "Multiple Document ID's selected".
Is this possible?
Filter Selected = IF ( CALCULATE ( HASONEVALUE ( MyTable[Document ID] ), ALLSELECTED ( MyTable ) ) = TRUE (), 1, 2 )- AUDISU
Resolver III
Hi Anonymous ,
Can you try this?
Filter Selected =IF (CALCULATE (HASONEVALUE ( MyTable[Document ID] ),ALLSELECTED ( MyTable ))= TRUE (),CONCATENATEX ( VALUES ( MyTable[Document ID] ) , [Document ID] , ",") ,"Multiple Document ID's selected")Thank you
- AlexisOlson
Super User
Is this what you're after?
Selected Document IDs = VAR _DocsSelected = COUNTROWS ( ALLSELECTED ( MyTable[Document ID] ) ) VAR _DocsTotal = COUNTROWS ( ALL ( MyTable[Document ID] ) ) RETURN IF ( _DocsSelected < _DocsTotal, CONCATENATEX ( ALLSELECTED ( MyTable[Document ID] ), [Document ID], ", " ), "All Document IDs selected" )- AnonymousNot applicable
Hi AlexisOlson Thanks for your reply! That would be a closer solution to the original problem but unfortunately it does not seem to work if there is an additional filter applied. For example, if i also apply a filter to show only one region (there are 2 regions, so let's say "HEP"), then selecting all the Document ID's does not show the text message "All Document IDs selected" but instead it just lists all the Document ID's. Is it possible to overcome this limitation?
- AlexisOlson
Super User
It doesn't show "All Document IDs selected" because not all IDs are selected (only ones from one region).
It's possible to overcome this if you can figure out what exactly "All" means if it doesn't actually mean all. Maybe try changing the _DocsTotal variable to something like this?
VAR _DocsTotal = CALCULATE ( DISTINCTCOUNT ( MyTable[Document ID] ), ALL ( MyTable[Document ID] ) )