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
StuartSmith
Power Participant
Power Participant

Set most recent date as default to slicer

I have a slicer that contains "Calendar Weeks" and currently the most recent date in the slicer is 27 April 2020, and would therefore like this to be th default date when the report loads, obviously I could publish it with that date set, but then when the 04 May 2020 appears in the slicer, I would like that date to be the default, and so it always sets the most recent date in the "Calendar Week" column as the default for the slicer.

 

Is this possible?

 

6 REPLIES 6
V-pazhen-msft
Community Support
Community Support

@StuartSmith 

In fact, there no straightforward way to select a category by default. As a workaround,You could add an additional slicer by creating a column, and select "the latest date".

 

Lastest Date Slicer = IF(Table[Date] = MAX(Table[Date]),LASTDATE(Table[Date]))

 

 

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

I figured out how to get the code working from the page https://powerpivotpro.com/2013/12/a-simple-trick-for-combating-stale-slicers/,

 

Latest_Date_Column = IF(Sheet1[Calender Week] = MAX(Sheet1[Calender Week]), "Latest", FORMAT (Sheet1[Calender Week], "DD/MM/YYYY"))
 

And getting the "latest" displaying in the drop down, but the other dates are not in order. I guess it becuase its formatted as text.  Any ideas how i can get the other dates in order?

 

date slicer.png

 

 

@StuartSmith this actually works, thks.

 

Im using this trick for "current year" and "current month", as my published report has one slicer for each. I dont have a date table with days, so my example could help someone else.

 

Also, its a good idea to show the user which are the "current" selections, somewhere on the report....that could be done in several ways, one of them using SELECTEDVALUE (TIME_TABLE[YEAR] ) used in a "CARD" visual.

 

CURRENT YEAR = 
SWITCH(
    TRUE();
    TIME_TABLE[YEAR] = MAX( TIME_TABLE[YEAR] ); "CURRENT YEAR";
    "PREVIOUS (" & FORMAT( TIME_TABLE[YEAR]; "0000" ) & ")"
)

CURRENT MONTH = 
SWITCH(
    TRUE();
    TIME_TABLE[YEAR_MONTH_NUMBER] = MAX( TIME_TABLE[YEAR_MONTH_NUMBER] ); "CURRENT MONTH";
    TIME_TABLE[MONTH_TEXT_COLUMN]
)

 

 

You could use the format  "YYYY/MM/DD" and it will orderning by default

blopez11
Resident Rockstar
Resident Rockstar

Thanks, that link does look like it may help, but having trouble understanding how it works, etc. such as what to do or where to put the code..etc. was hoping for step by step instructions.  

 

Can you remember how you got it working?

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.