Forum Discussion
Select All vs selecting nothing
Anonymous
Hi Xiaoxin Sheng
This is a very nice piece of code but doesn't quite work because 'select all' ticked or unticked returns 'None'. 'Select all' returns ISFILTERED as false: it isn't filtered as all values are selected. This is correct when ticked. But, when unticked then ISFILTERED still returns false. See below.
Select Status =
VAR _selected =
COUNTROWS ( VALUES ( Geography[GeographyName] ) )
VAR _all =
COUNTROWS ( DISTINCT ( ALL ( Geography[GeographyName] ) ) )
RETURN
IF (
ISFILTERED ( Geography[GeographyName] ),
IF ( _selected <> _all,
IF ( _selected > 1,
"Multiple",
"Single" ),
"ALL"
),
"None"
)
This is correct: all values are selected therefore nothing is filtered.
This is not correct: no values are selected, therefore everything is filtered out.
And just to clarify: if I select all the items individually (but don't tick the 'select all' button) then the measure returns the ALL value which is a different outcome to the first image above.
Is there another method where I can distinguish (per OP) between Select All ticked and Select All unticked?
I think that the problem ultimately is the Slicer visual: when it has nothing selected it should show nothing - instead it shows everything.
Thanks!
Hi belvoir99,
AFAIK, current filter functions are hard to recognize the difference between not selected and allselected(the default status). So the top two scenarios are equivalent for Dax ISFILTERED function.
My formula can be used to recognize the manually selected on the filter items except 'select all' option.
Regards,
Xiaoxin Sheng
- belvoir993 years agoResolver III
Thanks Anonymous Xiaoxin! I suspected there wasn't anything else possible but it was good to hear from you!
I won't mark this as a solution because it hasn't solved the problem.
Power BI tries to keep separate dashboard objects and their properties from DAX code and the data. However, it means that it is very limited in manipulating objects according to data value (via DAX).