Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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.

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

How about using a Bookmark?

 

1. Create a report page with default name of "Page 1".

page1.PNG

 

2. Insert a blank button with button text of "Last 7 days Filter" on "Page 1".

blank botton.jpg

button text.PNG

page1-button.PNG

 

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".

BOOKMARK.PNG

 

5. Set action of "Last 7 days Filter" button on "Page 1".

action.PNG

 

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".

filter.PNG

 

8. Update bookmark.

update bookmark.jpg 

 

9. Inset a Back button on "Bookmark of Last 7 days" page.

button back.jpg

 

10. Test.

bookmark.gif

 

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.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super 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

Anonymous
Not 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.

Icey
Community Support
Community Support

Hi @Anonymous ,

 

How about using a Bookmark?

 

1. Create a report page with default name of "Page 1".

page1.PNG

 

2. Insert a blank button with button text of "Last 7 days Filter" on "Page 1".

blank botton.jpg

button text.PNG

page1-button.PNG

 

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".

BOOKMARK.PNG

 

5. Set action of "Last 7 days Filter" button on "Page 1".

action.PNG

 

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".

filter.PNG

 

8. Update bookmark.

update bookmark.jpg 

 

9. Inset a Back button on "Bookmark of Last 7 days" page.

button back.jpg

 

10. Test.

bookmark.gif

 

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.