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

How to make a today,yesterday and 2 days before button.

Hi

 

I need to create 3 buttons: Today, Yesterday and 2 days before.
I tried using bookmarks but only succeeded in making Today button by using my date slicer relative date set to today - save to bookmarks and make a new button linked to that bookmark - problem I can't get back to original state anymore. Also this way doesn't work for yesterday or 2 days before because I can't set my date slicer to show only yesterday etc. ( should be dynamic not manually set to yesterday, since tomorrow today is yesterday )

I can make new columns with required dates but can't make a button out of columns.

I might add the report is in direct query.

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi , @Lyhis 
You can take a try this method that does not use bookmarks and buttons.

The steps are as follows:

1.Create a custom  as below:
Power query:

 

=if [Date] = Date.From(DateTime.LocalNow()) then "Today" else if [Date] =Date.From(Date.AddDays(DateTime.LocalNow(),-1)) then "Yesterday" else if [Date] =Date.From(Date.AddDays(DateTime.LocalNow(),-2)) then "2 Days Before" else [Date]

 

20.png

16.png

2.Then enter a table as below

17.png

3. Build relationships between tables,then you can drag the fields into the treemap to filter the data to achieve a similar effect
19.png

 

Best Regards,
Community Support Team _ Eason

 

View solution in original post

4 REPLIES 4
lbendlin
Super User III
Super User III

I prefer @v-easonf-msft solution but it requires import mode and daily dataset refresh - keep that in mind.

v-easonf-msft
Community Support
Community Support

Hi , @Lyhis 
You can take a try this method that does not use bookmarks and buttons.

The steps are as follows:

1.Create a custom  as below:
Power query:

 

=if [Date] = Date.From(DateTime.LocalNow()) then "Today" else if [Date] =Date.From(Date.AddDays(DateTime.LocalNow(),-1)) then "Yesterday" else if [Date] =Date.From(Date.AddDays(DateTime.LocalNow(),-2)) then "2 Days Before" else [Date]

 

20.png

16.png

2.Then enter a table as below

17.png

3. Build relationships between tables,then you can drag the fields into the treemap to filter the data to achieve a similar effect
19.png

 

Best Regards,
Community Support Team _ Eason

 

View solution in original post

lbendlin
Super User III
Super User III

"I need to create 3 buttons: Today, Yesterday and 2 days before."  Are you sure? Have you considered doing a horizontal slicer instead? Looks just like buttons.

"I might add the report is in direct query"  That is no longer a problem. You can have in-row calculated columns in direct query sourced tables.

I already have a date slicer but for some reason bosses want those buttons too, I don't know why either because slicer works just fine. I might aswell talk to them that its pointless.

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

April Update

Check it Out!

Click here to read more about the April 2021 Updates!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

secondImage

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.