Forum Discussion
Set most recent date as default to slicer
I figured out how to get the code working from the page https://powerpivotpro.com/2013/12/a-simple-trick-for-combating-stale-slicers/,
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?
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]
)