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
Kandarp
Helper I
Helper I

Default date range in date slicer

Hi,

 

I have a date slicer on my report. I want to add default date range like last 45 days on my slicer. So when the reports open for the first time it should dispaly last 45days date range. But When I click on the slicer, I should be able to select whatever dates are available in my calendar (e.g. from 2018 to today).

 

As of now I have added filter on my slicer but that makes other dates in disabled mode. (see screenshots) Is there any way to have all the dates enabled but default range is last 45 days.  (I do not want to use Filter as this is in embedded mode and user cant interact with filters)

 

Kandarp_2-1665568038726.png

Kandarp_3-1665568044763.png

 

 

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

Hi @Kandarp ,

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.

vluwangmsft_0-1665643828639.png

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

vluwangmsft_1-1665643914857.png

 

 

2. Then the measure can be created like

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

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

vluwangmsft_2-1665643976956.png

 

And similar question refer:

https://www.youtube.com/watch?v=KBEsPGxDxHM&feature=youtu.be 

https://forum.enterprisedna.co/t/how-to-default-last-12-months-in-date-between-slicer/18697/17 

 

 

Best Regards

Lucien

View solution in original post

2 REPLIES 2
Nayan_surya
Frequent Visitor

Hi @Kandarp 

 

My client also had this requirement that he needed to last week by default without any bookmark. What we ended up doing was buying a custom visual named Date Picker by Powerviz. It had this feature of default selection built in so made the job easy and the client happy.

 

Nayan_surya_0-1702627877774.png

 

 

if you can see in the above example the max week is selected by default. In your case, you can apply the preset like the last 45 days.

 

I think you should check them out.

Here is a link if you want to check this visual - https://appsource.microsoft.com/en-us/product/powerbivisuals/truvizinc1674781244292.date-picker-by-p...  (I believe they offer a free version too)

v-luwang-msft
Community Support
Community Support

Hi @Kandarp ,

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.

vluwangmsft_0-1665643828639.png

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

vluwangmsft_1-1665643914857.png

 

 

2. Then the measure can be created like

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

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

vluwangmsft_2-1665643976956.png

 

And similar question refer:

https://www.youtube.com/watch?v=KBEsPGxDxHM&feature=youtu.be 

https://forum.enterprisedna.co/t/how-to-default-last-12-months-in-date-between-slicer/18697/17 

 

 

Best Regards

Lucien

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.