Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Re: How to add lineal trend in Qlik sense

Hi Michael,

Could you please help . I want to display trend line in my QlikSense app but for some reason when i try to use your code it doesn't work.

Here is the code used:

linest_m(total aggr(if(sum(SalesDollars),sum(SalesDollars)),Year_Month),Year_Month)* 

only({1}Year_Month)+linest_b(total aggr(if(sum(SalesDollars),sum(SalesDollars)),Year_Month),Year_Month)

Year_Month is in this format 2014-2

I don't get any lines or point on my graph   when i try to use code above.

Thank you in advance.

1 Solution

Accepted Solutions
Michael_Tarallo
Employee
Employee

This definition will not work:

Month(OrderDate) & '-' & Year(OrderDate) as MonthYear

as it will be defined as $text $ascii

Regards,
Mike Tarallo
Qlik

View solution in original post

11 Replies
Michael_Tarallo
Employee
Employee

Hi Tigran,

Let me take a look, I'll get back to you soon.

Mike T

Qlik

Regards,
Mike Tarallo
Qlik
Michael_Tarallo
Employee
Employee

Hi Tigran,

Please see attached .qvf - just copy to your C:\Users\<user profile>\Documents\Qlik\Sense\Apps and refresh with F5 or restart Desktop. (In most cases it should refresh automatically)

Launch the  Sales Analysis with Master Calendar app

NOTE: I have used a Master Calendar with mine, to define the various date components.

Here is the expression:

I just replaced Sales and MonthYear:

linest_m(total aggr(if(sum(Sales),sum(Sales)),MonthYear),MonthYear)*

only({1}MonthYear)+linest_b(total aggr(if(sum(Sales),sum(Sales)),MonthYear),MonthYear)

If you need to get the Master Calendar to work with your data do this:

Locate the Calendar script and put in your date field here in this section:

Temp: 

    Load 

                   min(OrderDate) as minDate, 

                   max(OrderDate) as maxDate 

    Resident Orders; 

Define the data that you load with the date field (first should be on top of Calendar tab)

with the a table definition named Orders as in:

Your Data fro example:

Please mark the appropriate replies as CORRECT / HELPFUL so our team and other members know that your question(s) has been answered to your satisfaction.

Regards,

Mike Tarallo

Qlik

Regards,
Mike Tarallo
Qlik
Not applicable
Author

Thank you for the reply,

So i do have same exact filed like you have in your example

in my case its called MonthYearText  (example Dec-2014)

Im using this code and it doesn't work .

linest_m(total aggr(if(sum(SalesDollars),sum(SalesDollars)),MonthYearText),MonthYearText)*

only({1}MonthYearText)+linest_b(total aggr(if(sum(SalesDollars),sum(SalesDollars)),MonthYearText),MonthYearText)

Could you please explain i think i'm missing something here. I ran your application and it does work but when i do it in my app it doesn't.Do i need master calendar? i have exactly same filed defined in my app.

Thank you .

Michael_Tarallo
Employee
Employee

Hi Tigran - how is your MonthYearText defined - that may be the issue, as you can see how mine is defined in the screenshot:

It is $numeric,$integer, $timestamp, $date

You can see this in the data model viewer?

Did you use the Master Calendar that was in the app I gave you?

Can you attach your example?

Mike

Regards,
Mike Tarallo
Qlik
Michael_Tarallo
Employee
Employee

This definition will not work:

Month(OrderDate) & '-' & Year(OrderDate) as MonthYear

as it will be defined as $text $ascii

Regards,
Mike Tarallo
Qlik
Not applicable
Author

Than you for your help!

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Michael,

Any news on when a trend line tick box may find it's way into Sense?

Steve

Michael_Tarallo
Employee
Employee

Hi Steve, nothing yet plu‌ may know for us.

Thanks

Mike

Regards,
Mike Tarallo
Qlik
Patrik_Lundblad
Employee
Employee

Hi Steve & Mike,

It's high up on our roadmap, but I can't give a date.

Patrik.