Forum Discussion
How to set default MAX date in Slicer
Dear Team,
I have a date slicer on the page, I would like to select automatically most recent date(Max date) in the slicer when users open the dashboard. Can please help to share the logic. Apprecite the help!
Thanks
Thanks a lot, Sergii24. It works! I would like to show the maximum date as a date value,
example : Maximum date 14/09/2023 , is this possible, please. thanks
I'm glad it helped, Guru123 ! Unfotunately you can't add the date itself there as the whole concept is to make sure that your slicer value is static (so doesn't change after refresh).
You can add a "selected period" label somewhere in your report to underline what date is selected.
Remember to mark answer as solution so others can easily find it if the face a similar problem 🙂
Have a great day!
10 Replies
- Sergii24
Super User
Hi Guru123, filtering a dynamic date by default is a tricky thing! The biggest problem is not in defining a logic to select a specific date or date range, but in getting rid of previos label. For example, today your max date is 14/09/2023, so you creare a measure that gives you a desired result and the report is filtered as expected. However, tomorrow, when your measure will correctly point to 15/09/2022, the previous label of 14/09/2023 will remain selected (even if this date doesn't exist in your report anymore!). You'll need to select another value from a filter to make disappear "14/09/2023".
To overcome this problem, I would suggest you to create a calculated column in your Calendar Table, where for max date you'll return a label "Maximum date" and for the rest rows - corresponding date from a date column. In such you, "Maximum date" label will remain static (so there is no need to unclick it every day) but will point to different date depending on report refresh (remember that calcualted column value is calcualted when you refresh a report).Calculated column code:
Date for filter = VAR _MaxDate = MAX( 'Calendar Table'[Date] ) RETURN IF( 'Calendar Table'[Date] = _MaxDate, "Maximum date", FORMAT( 'Calendar Table'[Date], "dd/mm/yyyy" ) )- Guru123Frequent Visitor
Thanks a lot, Sergii24. It works! I would like to show the maximum date as a date value,
example : Maximum date 14/09/2023 , is this possible, please. thanks
- Sergii24
Super User
I'm glad it helped, Guru123 ! Unfotunately you can't add the date itself there as the whole concept is to make sure that your slicer value is static (so doesn't change after refresh).
You can add a "selected period" label somewhere in your report to underline what date is selected.
Remember to mark answer as solution so others can easily find it if the face a similar problem 🙂
Have a great day!
- Nayan_surya
Helper I
Hi Guru123
I've also faced a similar problem previously and wanted to add Max week, and Max month as options in the Date slicer.
I've found a Custom visual from Powerviz - named Date Picker.
It allows to have all of these preset in-built and has lot more features with free trial option.
You can check it out at https://shorturl.at/pAM18