Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Pinki_Lihitkar
Regular Visitor

Preselected Custom Slicer

Hello Everyone,

I am currently working on Preselected custom slicer visual and dealing the filter issue.

Explaination: I am using country_code, disease_code and attribute columns from a single table, still preselected slicer is not getting filter according to specific counry selection.

I wrote a measure to show dynamic defalut value according to Country selection from filter Panel and default value is showing properly only the problem is Alongwith default value it is showing all the attributes from all the country even when I applied the country filter.

Pinki_Lihitkar_0-1762342008612.png

 

1 ACCEPTED SOLUTION
JoacoFalcon
Regular Visitor

Hey there! 👋

This issue happens a lot when using preselected slicers — the default value works fine, but the slicer still shows all attributes from every country, right? 😅

Here are a couple of ways to fix it 👇

🩹 Option 1: Quick check

Go to your slicer settings and turn off “Show items with no data.”
That usually fixes it right away, since it forces the slicer to only display values that exist for the selected country.

But — if you’re using a custom visual like Preselected Slicer — it might ignore that setting. In that case, go for Option 2 👇

 

🧠 Option 2: Create a visibility measure

You can create a small measure that only returns 1 for attributes that actually have data for the selected country (and optionally disease).

Here’s a simple version:

Show Attribute (by Country) =
VAR _Country = SELECTEDVALUE(ff_country_d[country_code])
RETURN
IF(
ISBLANK(_Country),
1, // show all if no country selected
IF(
CALCULATE(
COUNTROWS(ff_summary),
ff_summary[country_code] = _Country
) > 0,
1, 0
)
)

If you also want it to react to the disease filter:

Show Attribute (Country + Disease) =
VAR _Country = SELECTEDVALUE(ff_country_d[country_code])
VAR _Disease = SELECTEDVALUE(ff_summary[custom_disease_code])
RETURN
IF(
ISBLANK(_Country) && ISBLANK(_Disease),
1,
IF(
CALCULATE(
COUNTROWS(ff_summary),
(_Country = BLANK() || ff_summary[country_code] = _Country),
(_Disease = BLANK() || ff_summary[custom_disease_code] = _Disease)
) > 0,
1, 0
)
)

How to use it

  1. Add your attribute field to the slicer.

  2. In the Filters pane (for the visual), add the measure Show Attribute....

  3. Filter it to show only values where it equals 1.

  4. Optional: turn off Show items with no data just to be safe.

That should do the trick 🎯
Your slicer will now only show the attributes related to the selected country (and disease, if included), while keeping your preselection logic working perfectly.

Hope it helps! 🙌



View solution in original post

6 REPLIES 6
Pinki_Lihitkar
Regular Visitor

Hello Everyone,

I am trying to filter the data from Preselected slicer, the values are not getting filter in a Grid even all the columns coming from same table.

Let's say, I have used Age in a Preselected slicer and Population in a Grid, both are coming from same table.

Still data is not getiing filter in a grid.

 

Any help would be appricated..!!!

Thanks.

mh2587
Super User
Super User

Default_Attribute_Selected = //Try this might help you
VAR SelectedCountry = SELECTEDVALUE(ff_summary[country_code])
VAR DefaultAttr =
    SWITCH(
        TRUE(),
        SelectedCountry = "AO", "2024",
        SelectedCountry = "CN", "All",
        SelectedCountry = "PT", "All",
        "All"
    )
RETURN
CALCULATE(
    MAX(ff_summary[attribute]),
    ff_summary[country_code] = SelectedCountry,
    ff_summary[attribute] = DefaultAttr
)

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



JoacoFalcon
Regular Visitor

Hey there! 👋

This issue happens a lot when using preselected slicers — the default value works fine, but the slicer still shows all attributes from every country, right? 😅

Here are a couple of ways to fix it 👇

🩹 Option 1: Quick check

Go to your slicer settings and turn off “Show items with no data.”
That usually fixes it right away, since it forces the slicer to only display values that exist for the selected country.

But — if you’re using a custom visual like Preselected Slicer — it might ignore that setting. In that case, go for Option 2 👇

 

🧠 Option 2: Create a visibility measure

You can create a small measure that only returns 1 for attributes that actually have data for the selected country (and optionally disease).

Here’s a simple version:

Show Attribute (by Country) =
VAR _Country = SELECTEDVALUE(ff_country_d[country_code])
RETURN
IF(
ISBLANK(_Country),
1, // show all if no country selected
IF(
CALCULATE(
COUNTROWS(ff_summary),
ff_summary[country_code] = _Country
) > 0,
1, 0
)
)

If you also want it to react to the disease filter:

Show Attribute (Country + Disease) =
VAR _Country = SELECTEDVALUE(ff_country_d[country_code])
VAR _Disease = SELECTEDVALUE(ff_summary[custom_disease_code])
RETURN
IF(
ISBLANK(_Country) && ISBLANK(_Disease),
1,
IF(
CALCULATE(
COUNTROWS(ff_summary),
(_Country = BLANK() || ff_summary[country_code] = _Country),
(_Disease = BLANK() || ff_summary[custom_disease_code] = _Disease)
) > 0,
1, 0
)
)

How to use it

  1. Add your attribute field to the slicer.

  2. In the Filters pane (for the visual), add the measure Show Attribute....

  3. Filter it to show only values where it equals 1.

  4. Optional: turn off Show items with no data just to be safe.

That should do the trick 🎯
Your slicer will now only show the attributes related to the selected country (and disease, if included), while keeping your preselection logic working perfectly.

Hope it helps! 🙌



Hello,

I wanted to set default year as latest year for Country code = RO else "All" for other countries. Attr1 column is a text so I converted it to numeric using Value() dax function and output of Value() converted to text using FORMAT() dax function. However, it still showing all the years as a default values.

Pinki_Lihitkar_0-1762858984664.pngPinki_Lihitkar_1-1762859020928.pngPinki_Lihitkar_2-1762859074915.png

 

Now, Default Value is showing as expected. In Preselected custom slicer it is still showing all the year value as default.

Pinki_Lihitkar_0-1762867614619.pngPinki_Lihitkar_1-1762867656574.png

 

Pinki_Lihitkar
Regular Visitor

I have Country and Preselection table and relationship is like one to many, country will Preselection table. In case of PBI defalut slicer country table filtering the attributes according to country selection and same with Preselected slicer it is not. So I wanted to confirm is there any limitation of Preselected Slicer. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.