powerbidaxpowerquery

Setting moving default start and end Date in power BI


I have a power BI report that need A default start date of two weeks ago and end date of Today. However, I also want the user to select other date ranges from the slicer if they want. Is there a way I can achieve it with power BI slicer? enter image description here

If yes How can I do it?


Solution

  • You need a second slicer to switch between your default date period (separate date table) and a custom date period.

    Date Periods = 
    UNION(
        ADDCOLUMNS(
            DATESBETWEEN('Calendar'[Date], TODAY() - 13, TODAY()),
            "Type", "Default"
        ),
        ADDCOLUMNS(
            CALENDAR(MIN('Calendar'[Date]),MAX('Calendar'[Date])),
            "Type", "Custom"
        )
    )
    

    Plus you need a measure to filter your first slicer depending on the selection.

    Slicer Filter = 
    IF(
        SELECTEDVALUE('Date Periods'[Type]) = "Custom",
        1,
        0
    )