cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

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

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Create a last 7 days date filter button which updates date slicer

Hi @spenot09 ,

 

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
Highlighted
Super User IV
Super User IV

Re: Create a last 7 days date filter button which updates date slicer

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



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Helper IV
Helper IV

Re: Create a last 7 days date filter button which updates date slicer

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

Highlighted
Community Support
Community Support

Re: Create a last 7 days date filter button which updates date slicer

Hi @spenot09 ,

 

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

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Community Summit Australia – Join Online!

Community Summit Australia – Join Online!

Be a part of the leading Microsoft Business Applications digital event, curated for the APAC community.

Top Solution Authors
Top Kudoed Authors