The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have 2 slicers , year and month.
I want to disable month slicer when no year slicer is selected.
I tryed using below dax functions
1. If(isfiltered(calendar[year]),1,0)
2. Int(isfiltered(calendar[year]))
I added into filter on the visual section and for both I filtered with 1.
It is working
But my issue here is.
When I selected both Year and month and if I deselect the year , month selected will remain as it is. Need solution for this.
I used both measures already. And currently I'm using reset slicer button. But still i want to see the solution for my issue.
Thanks
Hi @amshumansunkurd ,
You can create a separate month table, then refer the following videos to get it.
Dynamically Enable and Disable Slicers in Power BI - YouTube
Custom Date Period Selections in Power BI - YouTube
Solved: Re: Disabling Slicers when using another Slicer - Microsoft Fabric Community
Best Regards
Hi @amshumansunkurd ,
To address the issue where the Month slicer retains the selected month even after the Year slicer is deselected, you can use a DAX measure combined with a visual filter to dynamically enable or disable the Month slicer. Start by creating a measure to check if a year is selected. The measure can be written as follows:
EnableMonthSlicer =
IF(
ISFILTERED(Calendar[Year]),
1, -- Enable the Month slicer when a Year is selected
0 -- Disable the Month slicer when no Year is selected
)
This measure ensures that the Month slicer is only active when a year is selected. Once the measure is created, go to the Month slicer visual, drag the EnableMonthSlicer measure into the "Filters on this visual" section, and set the filter to show only values where the measure equals 1. This will prevent the Month slicer from being used when no year is selected.
If the issue persists where the selected month remains even after the Year slicer is deselected, you can extend the solution by ensuring that only valid months are shown when a year is selected. This can be done by creating a new calculated column or measure:
ValidMonth =
IF(
ISFILTERED(Calendar[Year]),
1, -- Show valid months
BLANK() -- Hide invalid months
)
This measure can also be added as a filter for the Month slicer, ensuring that only relevant months are displayed when a year is selected. Unfortunately, Power BI does not automatically clear a slicer's selection when its filter becomes invalid. To handle this limitation, you may consider adding a "Reset Filters" button or using Sync Slicers from the View tab in Power BI Desktop to synchronize the slicer behavior across multiple pages. These adjustments can help ensure a smoother user experience while maintaining the desired slicer functionality.
Best regards,