Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi everyone,
I'm trying to write a DAX measure that lists selected slicer values from the 'Country'[Country] column. Here's the behavior I want:
If none of the slicer values are selected → return "ALL"
If all available slicer values are selected → return "ALL"
If some values are selected → return only the selected country names
The catch is:
I have a report-level filter applied on 'Country'[Country] (e.g. only 4 countries are visible in the slicer). I want to respect this report-level filter but ignore slicer selections when calculating the total number of available countries.
Here’s the DAX I'm using:
Even though the report-level filter limits the countries to 4 (e.g. France, Germany, Mexico, USA), the VisibleCount always returns the full list (e.g. 5), because REMOVEFILTERS removes the report filter too.
A way to calculate the number of countries visible in the slicer (after report-level filtering), but not affected by the slicer selection.
Any ideas on how to achieve this in DAX? Please donwload the sample .pbix file here.
Thanks in advance!
Best Regards,
Pratik
Solved! Go to Solution.
Create a new table like
Country For Filter = DISTINCT( Country[Country] )
Create a one-to-many relationship from this new table to Country, so that 'Country for Filter' filters Country. Use this table to place the report level filter.
You can now create a measure like
Selected Countries =
VAR NumAllCountries = CALCULATE(
COUNTROWS( Country ),
REMOVEFILTERS( Country ),
VALUES( 'Country For Filter'[Country] )
)
VAR NumSelected = COUNTROWS( VALUES( Country[Country] ) )
VAR Result = IF( NumSelected = NumAllCountries, "All",
CONCATENATEX( VALUES( Country[Country] ), Country[Country], ", " )
)
RETURN Result
This works by removing the filters from Country, which also removes filters from 'Country for Filter' because it is in the expanded table, but then reapplying the filter from 'Country for Filter'.
Hi @PratikShetty,
Thank you for reaching out to Microsoft Fabric Community.
Thank you for sharing the detailed explanation, the issue here is the REMOVEFILTERS removes all filters including report/page level filters. That is why the VisibleCount shows all 5 countries from the table instead of the 4 visible in the slicer. Please use this below measure:
A_Filter_Country =
VAR Selected = VALUES('Country'[Country])
VAR SelectedCount = COUNTROWS(Selected)
VAR VisibleCountries = CALCULATETABLE (VALUES('Country'[Country]), ALLSELECTED('Country'[Country]))
VAR VisibleCount = COUNTROWS(VisibleCountries)
RETURN
IF (SelectedCount = 0 || SelectedCount = VisibleCount,
"ALL", CONCATENATEX (Selected, 'Country'[Country], ", " & UNICHAR(10)))
This works correctly based on your requirement and keeps the slicer’s behaviour consistent with report level filters.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thanks and regards,
Anjan Kumar Chippa
Create a new table like
Country For Filter = DISTINCT( Country[Country] )
Create a one-to-many relationship from this new table to Country, so that 'Country for Filter' filters Country. Use this table to place the report level filter.
You can now create a measure like
Selected Countries =
VAR NumAllCountries = CALCULATE(
COUNTROWS( Country ),
REMOVEFILTERS( Country ),
VALUES( 'Country For Filter'[Country] )
)
VAR NumSelected = COUNTROWS( VALUES( Country[Country] ) )
VAR Result = IF( NumSelected = NumAllCountries, "All",
CONCATENATEX( VALUES( Country[Country] ), Country[Country], ", " )
)
RETURN Result
This works by removing the filters from Country, which also removes filters from 'Country for Filter' because it is in the expanded table, but then reapplying the filter from 'Country for Filter'.
Hi @johnt75 ,
Your solution worked. I only needed to add the Filter table and the DAX worked.
Thanks a lot for guiding me.
Best Regards,
Pratik
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
76 | |
73 | |
42 | |
36 |
User | Count |
---|---|
109 | |
56 | |
52 | |
48 | |
43 |