Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
liam_hanninen
Creator
Creator

Displaying Slope/ Best Fit Line using Reference Line in a Scatter Plot Qlik Sense

I've explored many potential answers to this question. Many end up pointing to this answer How to add lineal trend in Qlik sense but it doesn't seem to work for a reference line in a scatter plot.


The attached qvf has the chart (Chart 1) from the above question and Chart 2 which is a scatter plot.  Below that chart I have KPIs representing the variables for Chart 1 such as the slope and y-intercept.


I'd like to create a best fit line for Chart 2. I'm thinking the code might look like:

linest_m(total aggr(sum(Profit),Country),Freight)* 

only({1}???)+linest_b(total aggr(sum(Profit),Country),Freight)


This mimics Chart 1 and is essentially y=mx+b.

  1. The equation is not correct-obviously
    1. What should go in the only() function?
    2. Even when it generates a line it returns a single value and therefore a straight line
  2. I don't know where the above equation would go even if it was correct
    1. Add-ons>X-axis reference lines
    2. Add-ons>Y-axis reference lines
    3. As a third measure

My question is: how do you create a best fit line using y=mx+b (or anything) on a scatter plot chart in Qlik Sense?

Thanks so much for any ideas and suggestions and hopefully answers.

3 Replies
Not applicable

Just wondering if you found a solution for this in Sense? Thanks!

liam_hanninen
Creator
Creator
Author

Nope. I decided to display best-fit with an excel graph haha. Or maybe I used mat plot lib. Either way it's too bad there is not a feature for this yet.

Not applicable

Thanks for the reply Liam, yeah, it's too bad as its functionality available in QV..