Professional Documents
Culture Documents
Calculating Trend Lines
Calculating Trend Lines
in Qlik Sense
I spent a little time working through the formulas required to mimic the trend lines that
are available in QlikView and currently not available in Qlik Sense without knowing
how to write reasonably complex expressions.
Here are some examples of exponential and 2nd order polynomial trend lines with
the relationship expressed as a formula in the subtitle.
To make things as clear as possible I have included the Excel variants of these
formulas so you have something to reference as I have done whilst checking these
formulas calculate correctly. These excel formulas were sourced from Excel Tips
From John Walkenbach: Chart Trendline Formulas
The below table shows the equivalent formulas in Qlik for the excel formulas
provided. I have also attached a QVF file with examples of each one so that you
have something real to reference as you build these into your own applications. In
addition I have included the excel file that I was using for testing to ensure my
calculations were correct.
Hi Andy,
Great to share different options so we can find the best fit for our needs but I'd be
cautious with your use of the term 'accurate'. To me the yellow line is more
representative of the trend than the red one but that is subjective...
If you solve the 3rd an 4th order polynomial lines please let me know as this was a
step too far for me ;-)
Cheers
Richard
Avkeep01
Valued Contributor
10-23-2018 10:00 AM
Hi Richard,
Thanks for your solution on the 2nd order polynomial. In your comments you wrote
that there is no equivalent INDEX(y,x^{1\2},1). I'm not sure if you already know that
{1\2} is an extra x -column. For example:
Y value X value
0,6931 1
0,7581 2
0,7553 3
the LINEST(Y:Y, X:X) = 0.0311. Same goes for LINEST_M in Qlik.
Adding the ^{1\2] leads to the following table in Excel (first x^1 and second x^2)
X-2
Y value X value
value
0,6931 1 1
0,7581 2 4
0,7553 3 9
With LINEST(Y:Y ; X:X-2) you'll get -0.0399 which is your C2 value.
So the LINEST_M in Qlik comes close to the LINEST function in Excel only I don't
exactly know how to get two X-columns into the LINEST_M function. Maybe you are
able to figure it out.
If you already knew about the two X-columns than you can ignore my post of course.