Forum Discussion
Clearing a slicer value
Hello,
I have a slicer based upon daily dates. I have a relative date filter for the last 7 days (not including today) on the page. So the range would be from 26 May 2020 to 01 Jun 2020.
If the user's last selection was 24 May 2020 and they went to the page today, 24 May is still selected and the page has no data due to the page level filter. Is there a way to not include that last value when they go to the page? It would seem like a refresh of the page would have made the value illegal.
Thanks
Hi Anonymous ,
maybe this helps to create a default filter element, what is always valid.
12 Replies
- mwegenerMost Valuable Professional
Hi Anonymous ,
take a look at this.
https://powerbi.microsoft.com/en-us/blog/announcing-persistent-filters-in-the-service/
- AnonymousNot applicable
Thanks for that, however doing the 'reset' would just return the slicer to a prior value. Single select slicers cannot (I don't think) start in an unselected state.
The issue I have is that the selected value is no longer valid for that page so I don't know why it persists. In the below graphic, I picked a week when I didn't have relative filtering set up. Then I put a relative filter of prior 6 calendar weeks, then expanded the slicer. The moment I click off the Feb 22 entry, it drops off the list.
I'm just trying to figure out how to no longer have it selected when the user goes back to the page without them having to do anything. If I could start out with nothing selected then the "reset to default" would work; however, it is a destructive operation. It clears all of the filters on all of the pages back to the default, and that is a bad practice as the user may want to have their report remain filtered to a specific department.
- edhansCommunity Champion
Another "gotcha" from Relative filtering.
Here is what I would suggest trying.
- Add a True/False field in your date table in Power Query like
= Duration.Days(DateTime.Date(DateTime.LocalNow()) - [Date]) <= 7 and Duration.Days(DateTime.Date(DateTime.LocalNow()) - [Date]) > 0- Filter your slicer on that field to only show TRUE values.
If your date table was built in DAX, you'd just need similar logic to get the true/false value.
In general, try to avoid calculated columns. There are times to use them, but it is rare. Getting data out of the source system, creating columns in Power Query, or DAX Measures are usually preferred to calculated columns. See these references:
Calculated Columns vs Measures in DAX
Calculated Columns and Measures in DAX
Storage differences between calculated columns and calculated tables
Creating a Dynamic Date Table in Power Query