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

set default date as last 7 days from present date in date slicer

I have date slicer which coming from date column contains date from 1-1-2017 to present date. currently date slicer shows min and max date but I want to set default date as last 7 days from present.

Constraints

  • I can manually change the from/to date in the same date slider. Just default from/to date will be last 7 days.
    • Example:
    • dhruv3_0-1678772633199.png
  • If data not available of last 7 days then default date should show the most recent 7 days as from/to date.

 

 

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

Hi @Anonymous ,

 

Currently, there is no such function to set a default value for the slicer. But you can achieve this goal through the following methods.

1.Create a seperate table by entering data. 

vtangjiemsft_0-1678933643966.png

Here I use the exclamation mark to make him the first place in the slicer. The slicer is set to single selection.

vtangjiemsft_1-1678933666812.png

2. Then the measure can be created like

 

 

Measure = IF(SELECTEDVALUE('Table (3)'[default value])="!previous 7 days",CALCULATE(SUM('Main table'[Value]),FILTER('Calendar',[Date]<=TODAY()&&[Date]>=TODAY()-6)),SUM('Main table'[Value]))

 

 

In this way, every time you open the report, the default is the data of the previous seven days. If you want to filter, select all from the single-choice slicer and filter the date range.

vtangjiemsft_2-1678933722173.png

You can use the selection pane on the View| menu as needed, and then hide the slicer.

vtangjiemsft_0-1679650084122.png

 

You can refer to the following links that may be helpful to you:

 set the date with the latest record as default dat... - Microsoft Power BI Community

Default Date Filters using Calculation Groups - How to easily build in Power BI - YouTube

Default Current Month Slicer in Power BI - How to default to the current month - YouTube

Set Default Slicer Selection to Current Year or Month in Power BI - YouTube

 

Best Regards,

Neeko Tang

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
Nayan_surya
Frequent Visitor

Hi,

 

There is a simpler solution I found to this problem while browsing through the custom visuals recently. It was a custom visual named Date Picker from Powerviz.

Without any Dax or extra effort, you can easily add all kinds of presets Like Max date, Max week, This week, Previous week, and all.

I think you can try it and add the previous week as a preset. Link to the Visual - https://shorturl.at/pAM18 ( I believe they do offer free version so check it out)

 

Nayan_surya_0-1702625167883.png

 

v-tangjie-msft
Community Support
Community Support

Hi @Anonymous ,

 

Currently, there is no such function to set a default value for the slicer. But you can achieve this goal through the following methods.

1.Create a seperate table by entering data. 

vtangjiemsft_0-1678933643966.png

Here I use the exclamation mark to make him the first place in the slicer. The slicer is set to single selection.

vtangjiemsft_1-1678933666812.png

2. Then the measure can be created like

 

 

Measure = IF(SELECTEDVALUE('Table (3)'[default value])="!previous 7 days",CALCULATE(SUM('Main table'[Value]),FILTER('Calendar',[Date]<=TODAY()&&[Date]>=TODAY()-6)),SUM('Main table'[Value]))

 

 

In this way, every time you open the report, the default is the data of the previous seven days. If you want to filter, select all from the single-choice slicer and filter the date range.

vtangjiemsft_2-1678933722173.png

You can use the selection pane on the View| menu as needed, and then hide the slicer.

vtangjiemsft_0-1679650084122.png

 

You can refer to the following links that may be helpful to you:

 set the date with the latest record as default dat... - Microsoft Power BI Community

Default Date Filters using Calculation Groups - How to easily build in Power BI - YouTube

Default Current Month Slicer in Power BI - How to default to the current month - YouTube

Set Default Slicer Selection to Current Year or Month in Power BI - YouTube

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Anonymous
Not applicable

@v-rzhou-msft @jdbuchanan71 can you please help me out?

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.