Forum Discussion

pbidani's avatar
pbidani
Frequent Visitor
1 year ago
Solved

Power BI - Calendar - Default Values

Hello, Please provide suggestions on how to create default settings on a calendar slicer -- so it defaults to start of the current year (i.e., 1/1/2024 or 1/1/2025 next year) and ends in the current...
  • shafiz_p's avatar
    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