Search code examples
graphicsqlikviewtrendline

How can I delimit the width of a trendline?


I have these variables:

X = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)

Y = (1, 5, 4, 9, 7, 8, 12, 20, 9, 7, 4, 1, 1, 2, 1, 1)

and I want to do a graphic with two visible partitions (X from 1 to 8 and X from 9 to 16). So, I set one dimension X and two expressions IF (X <= 8,Y) and IF (X > 8,Y). It works well and I got this:

Basic graphic

Now I want to include the linear trend line. But, after click in the proper option in the expressions tab, I got this:

Graphic with trend lines

which is not a good thing to see. I wished something like this:

Wished graphic with trend lines

Anyone knows how can I get a graphic like this last picture? Many thanks in advance.


Solution

  • If you want manually to calculate the linear Regression you have to use these functions LINEST_B and LINEST_M like this:

    linest_M(total aggr(Y,X),X)*X+ linest_b(total aggr(Y,X),X)
    

    but with some modifications because you split your expressions.

    Here is an example with your data set: enter image description here

    Here is the whole file

    from Qliks' help