Forum Discussion
Change in category selection changes selected subcategory in slicers
- 5 months ago
Hey, dikssha ; you can pull this off with a hack, sort of.
The thing with the non-disappearing previous selection is not fixable with default visuals; however, you can hack and adjust the behaviour.
The solution can look like this:
I have selected category B and subcategory B2. The table shows B2 correctly.
Then I select Category C. Subcategory will render C values with the B2 still selected. The table, however, will show hte first value for C category, so C1.
Lastly, I select new subcategory in C, so the B value will dissapear and Table will react to the subcategory selection.
If you have enough values, technically the preselected value can kinda dissapear. I don't think there's currently better way to do it.
The DAX that controls is set as Filter on visual level:
Measure Filter = var selectedCategory = SELECTEDVALUE(category[category]) var selectedSubCategory = SELECTEDVALUE(subcategory[subcategory]) var validSubCategories = CALCULATETABLE( VALUES(subcategory[subcategory]), subcategory[category] = selectedCategory, REMOVEFILTERS(subcategory) ) var isValidSelection = selectedSubCategory IN validSubCategories var alternativeSubCategory = MINX(validSubCategories, subcategory[subcategory]) var targetSubCategory = IF(isValidSelection, selectedSubCategory, alternativeSubCategory) var finalResult = CALCULATE( COUNTROWS('Table'), KEEPFILTERS(TREATAS({targetSubCategory}, 'Table'[subcategory])), REMOVEFILTERS(subcategory) ) return finalResultThe model looks like this:
I deliberately don't have a subcategory connected, which is a big disadvantage; to you can try playing with it, whether you make it work with the physical connection. Alternatively, if this is functionality just for one visual, you can have a separate dimension just for this, and then keep the rest of the report standard with proper relationships.
I am also attaching the report; you can try it yourself.
- 5 months ago
This is a really common issue when you have dependent slicers but no enforced relationship in the selection behavior.
From a technical side, Power BI doesn’t natively “reset” one slicer based on another selection — it will hold the last selected value, which is why you’re seeing blanks when the category changes.
A couple of approaches you could consider:
Using a hierarchy (Category → Subcategory) in a single slicer so the selections stay aligned
Creating a measure to handle default logic and avoid blanks in visuals
Or using synced slicers / bookmarks if you want more controlled behavior
That said, this is also one of those cases where it helps to think about the user experience.If changing Category can invalidate Subcategory, it might be worth either:
Clearing the subcategory selection automatically (instead of defaulting to one), or
Guiding the user with a visual cue when the selection becomes incompatible
I’ve run into similar situations where the bigger issue wasn’t the slicer behavior itself, but how easily a user could end up in a “no data” state without realizing why.Curious which direction you’re leaning — forcing a default selection, or making the interaction more transparent?
- 5 months ago
Hi dikssha
This feature is available the chiclet custom slicer visual but as the name says, it is s a chiclet/a button.
If you want to use a dropdown, you will have to modify a column's property in Tabular Editor. Please refer to this: https://community.fabric.microsoft.com/t5/Desktop/How-to-set-always-select-the-first-value-in-button-slicer/td-p/5000170
Hey, dikssha ; you can pull this off with a hack, sort of.
The thing with the non-disappearing previous selection is not fixable with default visuals; however, you can hack and adjust the behaviour.
The solution can look like this:
I have selected category B and subcategory B2. The table shows B2 correctly.
Then I select Category C. Subcategory will render C values with the B2 still selected. The table, however, will show hte first value for C category, so C1.
Lastly, I select new subcategory in C, so the B value will dissapear and Table will react to the subcategory selection.
If you have enough values, technically the preselected value can kinda dissapear. I don't think there's currently better way to do it.
The DAX that controls is set as Filter on visual level:
Measure Filter =
var selectedCategory = SELECTEDVALUE(category[category])
var selectedSubCategory = SELECTEDVALUE(subcategory[subcategory])
var validSubCategories =
CALCULATETABLE(
VALUES(subcategory[subcategory]),
subcategory[category] = selectedCategory,
REMOVEFILTERS(subcategory)
)
var isValidSelection = selectedSubCategory IN validSubCategories
var alternativeSubCategory = MINX(validSubCategories, subcategory[subcategory])
var targetSubCategory = IF(isValidSelection, selectedSubCategory, alternativeSubCategory)
var finalResult =
CALCULATE(
COUNTROWS('Table'),
KEEPFILTERS(TREATAS({targetSubCategory}, 'Table'[subcategory])),
REMOVEFILTERS(subcategory)
)
return finalResult
The model looks like this:
I deliberately don't have a subcategory connected, which is a big disadvantage; to you can try playing with it, whether you make it work with the physical connection. Alternatively, if this is functionality just for one visual, you can have a separate dimension just for this, and then keep the rest of the report standard with proper relationships.
I am also attaching the report; you can try it yourself.