Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello!
I have a scatter plot like the one below. However, what I need now is to have a trendline for each of my legend values. I previously saw this option in the analytics tab, but I can't find it anymore. How can I achieve this now?
This is the goal I want to achieve: "A scatter plot trend line is a straight line that is drawn on a scatter plot to visually represent the general direction and strength of the relationship between two variables. It's a way to summarize the overall pattern of points in a scatter plot, indicating whether there's a positive, negative, or no relationship"
Thanks
Solved! Go to Solution.
To add a trendline for each legend value in a Power BI scatter plot:
Note: Using a Date Hierarchy on the X-axis may cause issues with trendlines, especially when multiple months are selected, due to overlapping day values.
Hi @julsr ,
To add a trendline for each legend value in a scatter plot in Power BI:
If the option still doesn't appear, try updating Power BI Desktop to the latest version, as this feature may have been temporarily removed or changed.
Thank you both @v-venuppu ! The problem is that my X-axis is a Date Hierarchy. It works with one month as the days are not repeated, but when trying with multiple months, the values are incorrect (For example, if viewing from Jan 01 to Feb 01, the values for the first day appear at a single point on the x-axis.). Is it a limitation of the Power BI Scatter plot?
To add a trendline for each legend value in a Power BI scatter plot:
Note: Using a Date Hierarchy on the X-axis may cause issues with trendlines, especially when multiple months are selected, due to overlapping day values.
Thanks. This worked for the trendline, I'll open another post for the issue with multiple months.
Hi @julsr ,
Thank you for reaching out to Microsoft Fabric Community.
Unfortunately, Power BI’s built-in scatter plot supports only one trendline when no legend is used. Once you add a "Legend" field, the trendline option in the Analytics pane disappears - which is what you're seeing.
To achieve trendlines per group/legend, here's a working workaround:
1.Use Line and Clustered Column Chart or Line Chart Instead
Switch to a Line Chart or Line and Clustered Column Chart.
Place your X-axis (e.g., Date) and Y-values as normal.
Put your Category field (previously in the legend) in the "Legend" field.
This chart supports multiple series with their own lines, acting like trendlines.
If needed, smooth the lines in the Format pane.
2.Use Scatter Plot + DAX Trendline Calculation
If you must use a scatter plot, do the following:
Create a new DAX table with calculated trendline points for each category:
TrendData =
VAR Categories = VALUES(YourTable[Category])
RETURN
ADDCOLUMNS(
GENERATE(
Categories,
SELECTCOLUMNS(
YourTable,
"X", [YourXValue],
"Y", [CalculatedYTrendline] -- e.g. regression or average line
)
),
"Category", [Category]
)
For more details, you can refer to below Documentation:
Scatter, bubble, and dot plot charts in Power BI - Power BI | Microsoft Learn
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!
User | Count |
---|---|
85 | |
81 | |
64 | |
53 | |
46 |
User | Count |
---|---|
102 | |
49 | |
42 | |
39 | |
38 |