Forum Discussion

llealsantos's avatar
llealsantos
Frequent Visitor
1 year ago
Solved

Power BI: Dynamic Date Slicer Behavior

Hey all,

I have a date slicer that filters the last 14 months using a calculated column in the calendar table. When the "Last 14 Months" is selected on the slicer, it correctly displays only the last 14 months. However, when deselected, I’d like the slicer to show available years instead of months.

Is there a way to achieve this dynamic behavior?

Thanks!

  • Hi llealsantos 

    If I understood your question correctly, one way to achieve this is by modifying or adding a calculated column in your calendar table.

    The column should return "Last 14 Months" if the date falls within the last 14 months. Otherwise, it should return the year of the date.

    Then, you can use this new column as the slicer instead of the date column. This way, when "Last 14 Months" is selected, it will filter accordingly, and when it's deselected, it will show years instead.

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

7 Replies

  • Hi llealsantos 

    If I understood your question correctly, one way to achieve this is by modifying or adding a calculated column in your calendar table.

    The column should return "Last 14 Months" if the date falls within the last 14 months. Otherwise, it should return the year of the date.

    Then, you can use this new column as the slicer instead of the date column. This way, when "Last 14 Months" is selected, it will filter accordingly, and when it's deselected, it will show years instead.

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

    • AbimbolaArowolo's avatar
      AbimbolaArowolo
      Regular Visitor

      If I got your question correctly, try creating a calculated column like this:

      SlicerOption = IF([Date] >= EDATE(TODAY(), -14), FORMAT([Date], "MMM YYYY"), FORMAT([Date], "YYYY"))

      Use this in your slicer to dynamically switch between months and years based on selection.

  • v-prasare's avatar
    v-prasare
    Community Support

    Hi llealsantos

    As we haven’t heard back from you, we wanted to kindly follow up to check if the below solution provided for your issue worked? or let us know if you need any further assistance here?

     

     

     

    Thanks,

    Prashanth Are

    MS Fabric community support

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query

  • v-prasare's avatar
    v-prasare
    Community Support

    hi llealsantos,m

    As we haven’t heard back from you, we wanted to kindly follow up to check if the below solution provided for your issue worked? or let us know if you need any further assistance here?

     

     

     

    Thanks,

    Prashanth Are

    MS Fabric community support

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query

  • v-prasare's avatar
    v-prasare
    Community Support

    Hi @llealsantos,

    As we haven’t heard back from you, we wanted to kindly follow up to check if the below solution provided for your issue worked? or let us know if you need any further assistance here?

     

     

     

    Thanks,

    Prashanth Are

    MS Fabric community support

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly and give Kudos if helped you resolve your query