Forum Discussion
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.
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?
- Anonymous1 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
- lbendlin
Super User
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 - RPeruskiFrequent 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.
ID Date of Occurrence 1 1/17/2024 2 1/20/2024 3 1/24/2024 4 1/25/2024 5 1/30/2024 6 1/31/2024 7 2/16/2024 8 2/16/2024 9 2/21/2024 10 2/21/2024 11 2/22/2024 12 2/27/2024 13 2/27/2024 14 2/28/2024 15 2/29/2024 16 3/13/2024 17 3/14/2024 18 3/21/2024 19 3/26/2024 20 4/1/2024 21 4/16/2024 22 4/17/2024 23 4/18/2024 24 4/30/2024 25 5/21/2024 26 5/28/2024 27 6/10/2024 28 6/12/2024 29 6/13/2024 30 6/27/2024 31 6/28/2024 32 6/28/2024 33 7/2/2024 34 7/23/2024 35 7/24/2024 36 7/24/2024 37 7/25/2024 38 8/1/2024 39 8/9/2024 40 8/19/2024 41 8/20/2024 42 8/20/2024 43 9/2/2024 44 9/3/2024 45 9/10/2024 46 9/10/2024 47 9/12/2024 48 9/12/2024 49 9/12/2024 50 9/12/2024 51 9/16/2024 52 9/17/2024 53 10/3/2024 54 10/7/2024 55 10/17/2024 56 10/21/2024 57 10/21/2024 58 10/24/2024 59 10/28/2024 60 11/12/2024 61 11/13/2024 62 11/26/2024 63 12/2/2024 64 12/3/2024 65 12/4/2024 66 12/4/2024 67 12/6/2024 68 12/9/2024 69 1/10/2025 70 1/14/2025 71 1/16/2025 72 1/17/2025 73 1/17/2025 74 1/21/2025 75 1/24/2025 76 1/28/2025 77 2/12/2025 78 2/21/2025 79 2/24/2025 80 2/26/2025 81 3/3/2025 82 3/4/2025 83 3/4/2025 84 3/7/2025 85 3/11/2025 86 3/13/2025 87 4/8/2025 88 4/16/2025 89 4/22/2025 Date Year Month Month Number Quarter FiscalQuarter FiscalYear FY 1/1/2024 0:00 2024 Jan 1 Q1 Q3 FY2024 FY24 1/2/2024 0:00 2024 Jan 1 Q1 Q3 FY2024 FY24 1/3/2024 0:00 2024 Jan 1 Q1 Q3 FY2024 FY24 1/4/2024 0:00 2024 Jan 1 Q1 Q3 FY2024 FY24 1/5/2024 0:00 2024 Jan 1 Q1 Q3 FY2024 FY24 - lbendlin
Super 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?
- RPeruskiFrequent Visitor
Mainly focusing on a trendline from all data points. But this window function would be good for other projects I have too.
- AnonymousNot 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