Forum Discussion

BJankic's avatar
BJankic
Icon for Helper II rankHelper II
1 year ago

Dynamic Date Axis Based on Period Slicer (Day, Week, Month Granularity)

Hi,

I'm working on a report where I want to dynamically change both the time frame logic and the X-axis granularity based on a user-selected period from a slicer. Link to the file: Sample 

 

I have a slicer with the following period options (from a disconnected table PeriodTable[Period]):

  • MTD vs. Last Year MTD → show by days

  • QTD vs. Last Year QTD → show by weeks

  • Current YTD vs. Prior YTD → show by weeks

  • Rolling 90 days → show by weeks

  • Rolling 12 Months → show by months

My goal is to:

  • Use one line chart that dynamically adapts its X-axis to show the right level of date granularity based on the selected period

  • Display two measures:

    • Current Period (CurrentPeriod)

    • Same Period Last Year (SamePeriodLastYear)

  • Use a dynamic table (Date_Period) for the axis, which adjusts to day/week/month with proper labels and sorting

24 Replies

  • Thank you lbendlin for sharing the link. However, I would like to see a real solution based on the use case I provided. First, there is no date slicer, the calculation should be based on the selected timeframe. Also, how would you capture the Rolling 12 Months vs Rolling 12 Months Prior Year?

  • V-yubandi-msft's avatar
    V-yubandi-msft
    Icon for Community Support rankCommunity Support

    Hi BJankic ,

    Thank you for reaching out to the Fabric Community. I noticed that your sample file needs access permissions, so I couldn’t view your data directly. To assist, I recreated your situation with sample data and was able to achieve the dynamic time frame and axis granularity you mentioned.

     

    I’ve attached a PBIX file for your reference. Please take a look and let me know if you need any changes. I’m happy to help further.

     

    Best regards,

    Yugandhar.

    • BJankic's avatar
      BJankic
      Icon for Helper II rankHelper II

      Hi V-yubandi-msft , I’ve now allowed access to everyone with the link. However, this is not the solution I’m looking for.

      • V-yubandi-msft's avatar
        V-yubandi-msft
        Icon for Community Support rankCommunity Support

        Power BI does not currently allow you to dynamically change the X-axis granularity (such as day, week, or month) and values directly through a slicer. As an alternative, you can use bookmarks to switch between visuals with set granularities, though this approach may not provide complete dynamic axis control.

        Thanks&regards,
        Yugandhar.

  • V-yubandi-msft's avatar
    V-yubandi-msft
    Icon for Community Support rankCommunity Support

    Hi BJankic ,

    If your issue is resolved, that's good. If you need any further assistance or additional details, feel free to let me know.

    Thank you.

    • BJankic's avatar
      BJankic
      Icon for Helper II rankHelper II

      Hi V-yubandi-msft,

       

      The issue still isn’t resolved. There has to be a way to handle this with parameters and switch the X-axis to different date views, right?

      • V-yubandi-msft's avatar
        V-yubandi-msft
        Icon for Community Support rankCommunity Support

        Hi BJankic ,

        You're correct this can be done in Power BI using Field Parameters. Although Power BI doesn't let you change the X-axis granularity directly with a slicer, you can use Field Parameters to switch between different date fields such as Day, Week, or Month, depending on your selection. This way, you can dynamically adjust the X-axis in a single visual.

         

        Helpful Reference: Use report readers to change visuals - Power BI | Microsoft Learn

         

        Thank You.

  • V-yubandi-msft's avatar
    V-yubandi-msft
    Icon for Community Support rankCommunity Support

    Hi BJankic ,

    May I know if your issue has been resolved, or are you still facing any difficulties? If you need any additional information, please feel free to let us know.

     

    Thank You.

    • BJankic's avatar
      BJankic
      Icon for Helper II rankHelper II

      Hi V-yubandi-msft , no, it’s not. If you could share a working example or add it to the sample I shared, that would really help. Thank you!"