Forum Discussion
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:
"Please select a region" when no items are selected in the slicer.
"All regions selected" when all regions are selected.
"Regions selected: [List of regions]" when one to nine regions are selected.
Here is the DAX measure I have created:
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
- rohit1991
Super User
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], ", ") ) -
- MasonMA
Super User
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
Helper 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
Super 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
Community Support
Hi chetan8080 ,
Thanks for reaching out to the Microsoft fabric community forum.
Thanks for your prompt response
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.- chetan8080
Helper II
HELLO v-lgarikapat , I am still waiting for the solution
- v-lgarikapat
Community 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.