Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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 IDValidityRegion
399801/01/2018HEP
405001/01/2020HEP
405018/05/2020HEP
406011/01/2020HEP
413912/08/2020WAP
414501/01/2020WAP
414901/01/2020HEP
415725/11/2019HEP
416001/01/2020HEP
416008/04/2020HEP
416401/01/2020WAP
416601/01/2020HEP
418701/01/2020HEP
418707/12/2022HEP
418717/12/2023HEP
418719/12/2022HEP
424810/08/2022WAP
431401/01/2024HEP
447401/01/2020WAP
448101/01/2023WAP
448701/08/2020WAP
449501/11/2022WAP
468501/01/2024WAP
468801/01/2023WAP
469101/01/2023WAP
481310/12/2019WAP
483201/01/2021WAP
499701/01/2020HEP
  • AUDISU's avatar
    AUDISU
    4 years ago

    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's avatar
    AUDISU
    Icon for Resolver III rankResolver III

    Hi Anonymous ,

    Use following DAX with IF function.

    Measure =  CONCATENATEX ( VALUES ( MyTable[Document ID] ) , [Document ID] , ",")
    Thank you.
    • Anonymous's avatar
      Anonymous
      Not 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's avatar
        AUDISU
        Icon for Resolver III rankResolver 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
  • 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"
        )
    • Anonymous's avatar
      Anonymous
      Not 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's avatar
        AlexisOlson
        Icon for Super User rankSuper 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] )
            )