Forum Discussion

chetan8080's avatar
chetan8080
Icon for Helper II rankHelper II
1 year ago
Solved

DAX Measure Not Showing Correct Slicer State (All Selected, No Selection, Partial Selection)

Hello Power BI Community,

I am facing an issue with a DAX measure intended to dynamically display the state of a region slicer. The goal is to show one of three messages based on the user's selections.

My Goal

I want the measure to display:

  1. "Please select a region" when no items are selected in the slicer.

  2. "All regions selected" when all regions are selected.

  3. "Regions selected: [List of regions]" when one to nine regions are selected.

Here is the DAX measure I have created:

Selected Region Display =
VAR SelectedRegionsCount = COUNTROWS(VALUES('REGION TABLE'[REGION]))

RETURN
    IF(
        NOT ISFILTERED('REGION TABLE'[REGION]),
        "Please select a region",
        IF(
            SelectedRegionsCount >= 9,
            "All regions selected",
            "Regions selected: " & CONCATENATEX(VALUES('REGION TABLE'[REGION]), 'REGION TABLE'[REGION], ", ")
        )
    )

Working correctly for partial selections sa picture below:

 

Not working when nothing is selected 

 



  • Hi chetan8080 , 

    Thanks for the response.

    Could you please provide sample data that fully represents the issue or question you're referring to? Kindly ensure the data is in a usable format (e.g., PBIX,Excel or CSV) rather than a screenshot, and does not contain any sensitive or unrelated information.

    Looking forward to your response.

    Best regards,
    Lakshmi.

     

20 Replies

  • Hi chetan8080 

    In a default Power BI slicer:

    • If nothing is selected >> Power BI internally treats it as all selected.

    • If you click Select All >> the slicer state is also all selected.

    Create Measure:

    Selected Region Display = 
    VAR RegionCount = COUNTROWS(VALUES('Sample Data'[Region]))
    VAR TotalRegions = COUNTROWS(ALL('Sample Data'[Region]))
    RETURN
    SWITCH(
        TRUE(),
        RegionCount = 0, "Please select a region",
        RegionCount = TotalRegions, "All regions selected",
        "Regions selected: " &
            CONCATENATEX(VALUES('Sample Data'[Region]), 'Sample Data'[Region], ", ")
    )

     

     

     

     

  • chetan8080 

     

    Hi, You can use this sample code,

     

    But your end users would need to understand when None is selected (Select All not checked) it actually means everything is selected. 

    Display = 
    VAR SelectedRegionsCount =
        COUNTROWS(VALUES('Table'[REGION]))
    VAR TotalRegionsCount =
        COUNTROWS(ALL('Table'[REGION]))
    RETURN
        SWITCH(
            TRUE(),
            SelectedRegionsCount = 0, 
                "Please select a region",
            SelectedRegionsCount = TotalRegionsCount,
                "All regions selected",
            "Regions selected: " &
                CONCATENATEX(
                    VALUES('Table'[REGION]),
                    'Table'[REGION],
                    ", "
                )
        )

        

     

     

     

     

     

    • chetan8080's avatar
      chetan8080
      Icon for Helper II rankHelper II

      Hi MasonMA , thank you for responding.
      I need the dax to display "Please select a region" when nothing is selected from the slicer.

      • MasonMA's avatar
        MasonMA
        Icon for Super User rankSuper User

        Hi, then i would suggest disabling 'Select All' and use below sample code 

        Display = 
        VAR _SelectedRegions =
            VALUES('Table'[REGION])
        VAR _SelectedRegionsCount =
            COUNTROWS(_SelectedRegions)
        VAR _TotalRegionsCount =
            COUNTROWS(ALL('Table'[REGION]))
        VAR _IsFiltered =
            ISFILTERED('Table'[REGION])
        VAR _result=
            SWITCH(
                TRUE(),
                NOT _IsFiltered || _SelectedRegionsCount = 0,
                    "Please select a region",
                _SelectedRegionsCount = _TotalRegionsCount,
                    "All regions selected",
                "Regions selected: " &
                    CONCATENATEX(
                        _SelectedRegions,
                        'Table'[REGION],
                        ", "
                    )
            )
        
        RETURN _result

         

            

         

         

  • v-lgarikapat's avatar
    v-lgarikapat
    Icon for Community Support rankCommunity Support

    Hi chetan8080 ,

     

    Thanks for reaching out to the Microsoft fabric community forum.

    MasonMA , rohit1991 

    Thanks for your prompt response

    chetan8080 , 

    I wanted to follow up and confirm whether you’ve had the opportunity to review the information  provided by MasonMA , rohit1991 . If you have any questions or need further clarification, please don’t hesitate to reach out.

     

    We appreciate your engagement and thank you for being an active part of the community.

    Best regards,
    Lakshmi.

      • v-lgarikapat's avatar
        v-lgarikapat
        Icon for Community Support rankCommunity Support

        Hi chetan8080 , 

        Thanks for the response.

        Could you please provide sample data that fully represents the issue or question you're referring to? Kindly ensure the data is in a usable format (e.g., PBIX,Excel or CSV) rather than a screenshot, and does not contain any sensitive or unrelated information.

        Looking forward to your response.

        Best regards,
        Lakshmi.