Forum Discussion
Power BI - Calendar - Default Values
- 1 year ago
Hi pbidani You can achieve this by using a calculated column and use that column to filter the slicer to show the default date range initially.
Considering You have date table set up. If not you can create a date table using the code below:DateTable = ADDCOLUMNS( CALENDAR(DATE(2020,1,1), DATE(2025, 12, 31)), "Year", YEAR([Date]), "Month", MONTH([Date]), "Day", DAY([Date]) )
Then create a new column to identify the default date range:IsDefaultDate = IF( [Date] >= DATE(YEAR(TODAY()), 1,1) && [Date] <= TODAY(), 1, 0 )Add the [Date] field from your date table to the slicer. Use the IsDefaultDate column to filter the slicer to show the default date range initially. See image:
This meets your first requirement.
To achieve the second requirement, which is the flexibility to extend the date range in the slicer earlier than first day of the current year or beyond today, You need to use bookmark.
So, I have created 2 slicer, one for default range and one for all range. Then place both on top of another and set up a bookmark nevigator button. You can create your own tiny button to switch slicer. See image:Hope this helps!!
If this solved your problem, please accept it as a solution and a kudos!!
Best Regards,
Shahariar Hafiz
Create a measure:
IsInDefaultRange =
IF(
'DateTable'[Date] >= DATE(YEAR(TODAY()), 1, 1) &&
'DateTable'[Date] <= TODAY(),
1,
0
)
Add this measure to visual level filter and filter for '1'
💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn