Forum Discussion

RPeruski's avatar
RPeruski
Frequent Visitor
1 year ago
Solved

Adding Trendline to a Line Graph While Showing Fiscal Year & Quarters

Hello,

 

I would like to add a trendline to the graph below however the X-axis is not continuous. I've attempted to change around the date table but to no success. If I need to change around the date information, then how can I change the formating of the X-axis to still end up with this FY, Quarter, Mon formatting. 

 

 

  • lbendlin's avatar
    lbendlin
    1 year ago

    Thank you for the sample data. Which trend methodology do you want to apply?  Sliding window? how wide?  

    Here is an example of a "five wide"  window.

     

    Or do you want to find the trend based on all data points?

     

     

     

     

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi RPeruski ,

     

    To add a proper overall trendline in your visual, while keeping your Fiscal Year / Quarter / Month formatting, you need to retain a continuous axis for LINESTX to work correctly, but custom-format the display of the X-axis.

    We can do a few workarounds:

    1.Make sure your 'Calendar'[Date] column is marked as the primary date column (it should be of type Date and continuous).

     

    2.We need to use LINESTX properly:

     

    TotalTrend =
    VAR a =
        SUMMARIZE(
            ALLSELECTED('Calendar'),
            'Calendar'[Date],
            "ct", [ct]
        )
    VAR b =
        EVALUATEANDLOG(
            LINESTX(a, [ct], [Date])
        )
    RETURN
        CALCULATE(
            b,
            KEEPFILTERS('Calendar'[Date])
        )

     

    You may also use 'Calendar'[YearMonth] if you have a combined column, but 'Date' ensures continuity.

    3.Instead of breaking the X-axis continuity for FY/Quarter/Month display, use a custom tooltip or dynamic label:

    Create a new calculated column in your date table:

    X-Axis Label = 'Calendar'[Month] & " " & 'Calendar'[FiscalQuarter] & " " & 'Calendar'[FY]      

             Use this for tooltips or a slicer, but do not use it for the axis. Keep the actual X-axis as a continuous date.

    4.In the visual formatting pane:

    • Go to X-axis > Type > Continuous
    • Optionally, hide the axis labels if the formatting is messy, and use tooltips to convey the fiscal context.

    If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!

    Regards,

    B Manikanteswara Reddy

10 Replies

  • you would have to compute that trendline yourself.  Usually you can use LINESTX for that.  If you like more help please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
    Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
    Please show the expected outcome based on the sample data you provided.

    Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
    Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

  • RPeruski's avatar
    RPeruski
    Frequent Visitor

    Can you provide additional context to how to use LINESTX for this data? See the tables below for the calendar table I'm using and the data that feeds the line graph. I can't post the entire calendar table due to size restrictions but you can get the gist of the data.

     

    IDDate of Occurrence
    11/17/2024
    21/20/2024
    31/24/2024
    41/25/2024
    51/30/2024
    61/31/2024
    72/16/2024
    82/16/2024
    92/21/2024
    102/21/2024
    112/22/2024
    122/27/2024
    132/27/2024
    142/28/2024
    152/29/2024
    163/13/2024
    173/14/2024
    183/21/2024
    193/26/2024
    204/1/2024
    214/16/2024
    224/17/2024
    234/18/2024
    244/30/2024
    255/21/2024
    265/28/2024
    276/10/2024
    286/12/2024
    296/13/2024
    306/27/2024
    316/28/2024
    326/28/2024
    337/2/2024
    347/23/2024
    357/24/2024
    367/24/2024
    377/25/2024
    388/1/2024
    398/9/2024
    408/19/2024
    418/20/2024
    428/20/2024
    439/2/2024
    449/3/2024
    459/10/2024
    469/10/2024
    479/12/2024
    489/12/2024
    499/12/2024
    509/12/2024
    519/16/2024
    529/17/2024
    5310/3/2024
    5410/7/2024
    5510/17/2024
    5610/21/2024
    5710/21/2024
    5810/24/2024
    5910/28/2024
    6011/12/2024
    6111/13/2024
    6211/26/2024
    6312/2/2024
    6412/3/2024
    6512/4/2024
    6612/4/2024
    6712/6/2024
    6812/9/2024
    691/10/2025
    701/14/2025
    711/16/2025
    721/17/2025
    731/17/2025
    741/21/2025
    751/24/2025
    761/28/2025
    772/12/2025
    782/21/2025
    792/24/2025
    802/26/2025
    813/3/2025
    823/4/2025
    833/4/2025
    843/7/2025
    853/11/2025
    863/13/2025
    874/8/2025
    884/16/2025
    894/22/2025

     

    DateYearMonthMonth NumberQuarterFiscalQuarterFiscalYearFY
    1/1/2024 0:002024Jan1Q1Q3FY2024FY24
    1/2/2024 0:002024Jan1Q1Q3FY2024FY24
    1/3/2024 0:002024Jan1Q1Q3FY2024FY24
    1/4/2024 0:002024Jan1Q1Q3FY2024FY24
    1/5/2024 0:002024Jan1Q1Q3FY2024FY24
    • lbendlin's avatar
      lbendlin
      Icon for Super User rankSuper User

      Thank you for the sample data. Which trend methodology do you want to apply?  Sliding window? how wide?  

      Here is an example of a "five wide"  window.

       

      Or do you want to find the trend based on all data points?

       

       

       

       

      • RPeruski's avatar
        RPeruski
        Frequent Visitor

        Mainly focusing on a trendline from all data points. But this window function would be good for other projects I have too. 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi RPeruski ,

     

    We would like to follow up to see if the solution provided by the super user lbendlin resolved your issue. Please let us know if you need any further assistance.

     

    If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

     

    Regards,

    B Manikanteswara Reddy