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

Last 12 months Line Graph

Hi All,

I have a user requirement. He wants to see 12 months trends of particular KPI's in line graph. I have months from Jan to Dec as filter selections. His requirement is when November 2015 is selected, Graph should be plotted from November 2014 to November 2015 i.e trend should be seen from Nov to Nov. When Dec 2015 is selected, line graph should show trend from Dec 2014 to Dec 2015. Likewise when July 2015 is selected, July 2014 to July 2015 to be shown.


How can I achieve this dynamic behavior? 

1 Solution

Accepted Solutions
ecolomer
Master II
Master II

5 Replies
sunny_talwar

Use Set analysis like this:

=Sum({<DateField = {"$(='>=' & Date(AddYears(Max(DateField), -1), 'YourDateFieldFormat') & '<=' & Date(Max(DateField), 'YourDateFieldFormat'))"}>}Sales)

jolivares
Specialist
Specialist

This a typical case for use set analysis.  In your expression you need say to QV that you need this set of data:

For instance:  Sum({<MyYear, MyMonth, MyYeMon={">=$(=Max(MyYeMon)-12)"}>} Sales)

Assuming you have a field containing then plus the month (201511),when the user select November 2015, Qlik search the set of data where month.

Not applicable
Author

Thanks Sunny, I will try.

ecolomer
Master II
Master II

See this:

triekong
Creator
Creator

ecolomer

thanks for the solution i have done this. i know this thread is old but

But i have a hitch: what if i wanted to display all the Months on the x axis. regardless of if i have data in the months or not.

for example: if March 2017 data = 0, and December 2017 is selected, i still want my chart x axis to read from: Dec2016, Jan2017, Feb2017, March2017,Apr2017, May2017 ,June2017 ,July2017 ,Aug2017, Sept2017, Oct2017, Nov2017 ,Dec2017


Any thoughts on this? !