Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
Creator III
Creator III

Draw Explicit Trend Line in Scatter Chart

Hello,

I have the following Scatter Chart:

1.png

With Dimension = Month, and Expressions = ONLY(Month) and SUM(Sales).


What I needed is to get the Trend Line formula (y=mx+b) showed on the chart.


I got that by using:

for M value = linest_m(total aggr(sum(Sales),Month),Month) -> -1.1783

for B value = linest_b(total aggr(sum(Sales),Month),Month) -> 26.742

The thing is I need to draw that line as a reference line on the chart (without using the automatic trend line) and get it fixed with those values, even if I make selections.

Do you know how could I do that?

I attach the QVW file.

Thanks.

1 Reply
effinty2112
Master
Master

Hi Micro,

This is at least close to what you need.

Remove the trendline you have.

Add this expression:

=LINEST_M({1}Total Aggr(sum({1}Sales),Month),Month) * Month

+LINEST_B({1}Total Aggr(sum({1}Sales),Month),Month)

Add a trendline to this one.

In the Axes tab make the x and y static min =1

Make the x static max : Max({1}Month) +1

Make the y static max : 20+max({1}Aggr(sum({1}Sales),Month))


1.jpg

Now if you pick a few points we get :


2.jpg

Sadly the line disappears if you select one point only - hope that's not too disappointing. Maybe a little tweak can correct this.


Cheers


Andrew