Forum Discussion

RajiKarthik's avatar
RajiKarthik
Regular Visitor
5 days ago
Solved

Power BI - Slicer Control

I need a slicer selection to appear and disappear based on a parameter slicer selection:

I have 3 metrics in my parameter: Student Enrollment, Course Enrollment and Credit Hours

Whenever student enrollment is selected, the user should be provided with an additional slicer option, "Area of Study Category", and for other metrics, it should stay invisible.

I created control DAXs "Show Area of Study Slicer"  and "Area of Study Slicer Header". Added the "Show Area of Study Slicer" to the visual level filter and set it to 1. Similarly added the "Area of Study Slicer Header" to the header control, so the header disappears too.

Issue  - Header disappears, but if I make any selection in the "Area of Study Category" slicer and then change the metric to "Course Enrollment", then the slicer remains with only the selected value. Other values disappear, though. But I want the whole slicer to disappear when the metric parameter changes. Experts, please help! Thanks in advance!!

Parameter Definition:

Metric Selector =

DATATABLE(

    "Metric Key", INTEGER,

    "Metric Name", STRING,

    "Sort Order", INTEGER,

    "Department Map", STRING,

    {

        { 1, "Student Enrollment", 1, "Student" },

        { 2, "Course Enrollment", 2, "Course" },

        { 3, "Credit Hours", 3, "Course" }

    }

)

Control DAXs to use in the filter & Header:

Show Area of Study Slicer =

VAR MetricKey = SELECTEDVALUE('Metric Selector'[Metric Key], 1)

RETURN

    IF(MetricKey = 1, 1, 0)

Area of Study Slicer Header =

VAR MetricKey = SELECTEDVALUE('Metric Selector'[Metric Key], 1)

RETURN

    IF(MetricKey = 1, "Area of Study Category", "")

  • Hi RajiKarthik​,

    Both replies above are correct: your DAX can control which values are displayed in the slicer, but it can't actually clear the slicer's existing selection or dynamically change the visibility of the slicer visual itself.

    If your requirement is specifically:

    Student Enrollment → show Area of Study slicer
    Course Enrollment / Credit Hours → hide it and clear any previous Area selection

    then I would use bookmarks rather than the Metric Selector slicer as the user-facing control.

    Power BI bookmarks can capture both the current slicer state and visual visibility, as documented in Microsoft's bookmark guidance.

    I would create three bookmark states:

    Student Enrollment

    • Metric Selector = Student Enrollment
    • Area of Study slicer visible
    • Area of Study selection cleared


    Course Enrollment

    • Metric Selector = Course Enrollment
    • Area of Study slicer hidden
    • Area of Study selection cleared


    Credit Hours

    • Metric Selector = Credit Hours
    • Area of Study slicer hidden
    • Area of Study selection cleared


    Then expose those three states through a Bookmark Navigator instead of having the user directly interact with the Metric Selector slicer.

    For the bookmarks, keep Data enabled so the slicer selections are captured, and Display enabled so the Area slicer's visibility is captured.

    I would also use Selected visuals rather than All visuals if you have other slicers on the page that should retain their current selections. In that case, include only the Metric Selector, Area of Study slicer, and any associated header/shape in those bookmarks.

    You can keep your Metric Selector slicer hidden on the page; the bookmarks will change its selected value, so your existing measures using SELECTEDVALUE('Metric Selector'[Metric Key]) can continue working.

    The important limitation is that if you keep the current Metric Selector slicer as the thing users click, there isn't a native DAX mechanism that can automatically fire a bookmark or clear another slicer when that selection changes. That is why the old Area selection remains even though your visual-level filter makes the slicer appear empty.

    So for a true show/hide + reset experience, I would make the bookmark navigator the metric selector rather than trying to solve the state reset with another DAX measure.

    AI-assisted drafting: AI was used to help structure and phrase this response. I reviewed and validated the technical content before posting.

4 Replies

  • Hi RajiKarthik​,

    Your DAX is fine. The issue is that a visual-level filter can hide the slicer’s values, but it cannot actually hide or reset the slicer itself.

     So when you select “Area of Study Category” and then switch to Course Enrollment, Power BI keeps the previous slicer selection.

     Unfortunately, DAX can’t dynamically clear another slicer or change its visibility.

     For a true show/hide effect, you’ll need to use a different approach such as bookmarks/Selection pane or redesign the interaction.

  • Hi RajiKarthik​ 

    While DAX can influence which rows are visible, it cannot reset or modify slicer selections. A workaround is to use a disconnected table for the slicer so it does not directly affect the visual. A conditional measure can then determine when to show the category values, such as when the selected subcategory does not exist under the selected category.

    Please see the attached pbix.

  • ShivekMaharaj's avatar
    ShivekMaharaj
    Icon for Memorable Member rankMemorable Member

    Hi RajiKarthik​,

    Both replies above are correct: your DAX can control which values are displayed in the slicer, but it can't actually clear the slicer's existing selection or dynamically change the visibility of the slicer visual itself.

    If your requirement is specifically:

    Student Enrollment → show Area of Study slicer
    Course Enrollment / Credit Hours → hide it and clear any previous Area selection

    then I would use bookmarks rather than the Metric Selector slicer as the user-facing control.

    Power BI bookmarks can capture both the current slicer state and visual visibility, as documented in Microsoft's bookmark guidance.

    I would create three bookmark states:

    Student Enrollment

    • Metric Selector = Student Enrollment
    • Area of Study slicer visible
    • Area of Study selection cleared


    Course Enrollment

    • Metric Selector = Course Enrollment
    • Area of Study slicer hidden
    • Area of Study selection cleared


    Credit Hours

    • Metric Selector = Credit Hours
    • Area of Study slicer hidden
    • Area of Study selection cleared


    Then expose those three states through a Bookmark Navigator instead of having the user directly interact with the Metric Selector slicer.

    For the bookmarks, keep Data enabled so the slicer selections are captured, and Display enabled so the Area slicer's visibility is captured.

    I would also use Selected visuals rather than All visuals if you have other slicers on the page that should retain their current selections. In that case, include only the Metric Selector, Area of Study slicer, and any associated header/shape in those bookmarks.

    You can keep your Metric Selector slicer hidden on the page; the bookmarks will change its selected value, so your existing measures using SELECTEDVALUE('Metric Selector'[Metric Key]) can continue working.

    The important limitation is that if you keep the current Metric Selector slicer as the thing users click, there isn't a native DAX mechanism that can automatically fire a bookmark or clear another slicer when that selection changes. That is why the old Area selection remains even though your visual-level filter makes the slicer appear empty.

    So for a true show/hide + reset experience, I would make the bookmark navigator the metric selector rather than trying to solve the state reset with another DAX measure.

    AI-assisted drafting: AI was used to help structure and phrase this response. I reviewed and validated the technical content before posting.