Forum Discussion
Create a last 7 days date filter button which updates date slicer
Hi, I'd like to implement a last 7 days date filter that would be represented as a button. At the same time, the user should have the option to select a custom date range with the slicer. For example if today is March 7th and the custom date slicer is set to show data from February 12 - February 17 but then the "Last 7 Days" button is pressed, dates from March 1 - March 7 should still be shown. In a way, the button should override the date filter selected in the slicers.
Hi Anonymous ,
How about using a Bookmark?
1. Create a report page with default name of "Page 1".
2. Insert a blank button with button text of "Last 7 days Filter" on "Page 1".
3. Duplicate "Page 1" and rename it as "Bookmark of Last 7 days".
4. In Bookmark pane, add "Bookmark of Last 7 days" page as a bookmark and rename it as "Bookmark of Last 7 days".
5. Set action of "Last 7 days Filter" button on "Page 1".
6. Create a Measure.
Last 7 days filter Measure = VAR DateDiff_ = DATEDIFF ( MAX ( 'Table'[Date] ), TODAY (), DAY ) RETURN IF ( DateDiff_ <= 7, 1 )7. Put "Last 7 days filter measure" on "Filters on this visual" of each visualyou want to filter on "Bookmark of Last 7 days" page, and apply filter of "is 1".
8. Update bookmark.
9. Inset a Back button on "Bookmark of Last 7 days" page.
10. Test.
For more details, please check the attached PBIX file.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- amitchandakSuper User
I think you use some custom slicer. The relative will not allow date and the range base will not automatically select and another date.
https://docs.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range
- AnonymousNot applicable
amitchandak exactly, only using a relative slicer does not integrate well with an already existing date slicer as you have to make sure the date slicer covers the relative slicers date range. Not a great solution.
- IceyCommunity Support
Hi Anonymous ,
How about using a Bookmark?
1. Create a report page with default name of "Page 1".
2. Insert a blank button with button text of "Last 7 days Filter" on "Page 1".
3. Duplicate "Page 1" and rename it as "Bookmark of Last 7 days".
4. In Bookmark pane, add "Bookmark of Last 7 days" page as a bookmark and rename it as "Bookmark of Last 7 days".
5. Set action of "Last 7 days Filter" button on "Page 1".
6. Create a Measure.
Last 7 days filter Measure = VAR DateDiff_ = DATEDIFF ( MAX ( 'Table'[Date] ), TODAY (), DAY ) RETURN IF ( DateDiff_ <= 7, 1 )7. Put "Last 7 days filter measure" on "Filters on this visual" of each visualyou want to filter on "Bookmark of Last 7 days" page, and apply filter of "is 1".
8. Update bookmark.
9. Inset a Back button on "Bookmark of Last 7 days" page.
10. Test.
For more details, please check the attached PBIX file.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.