Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
souvik
Contributor
Contributor

Selecting Multiple Months of a year in Line chart

Hi All,

Here i have a query since i am new to qliksense

I have a requirement where i need to show the data of all the months of year 2014 and simultaneaously i also need to show all the months of year 2015, in a line chart, means i need to have two dimensions 1)All the months of 2015

2)All the months of 2014

i have already segregated the "month" and "year" filed from a "Date" field using    Month (Date) as Month,
Year(Date) as Year, .

 

Can anyone please answer to my query?

1 Reply
Mauritz_SA
Partner - Specialist
Partner - Specialist

Hi @souvik 

Assuming you have this kind of data:

LOAD * Inline [
Date,Sales
2012/12/02,400
2013/01/01,880
2013/02/01,90
2013/03/01,370
2013/04/01,910
2013/05/01,880
2013/06/01,220
2013/07/01,860
2013/08/01,930
2013/09/01,200
2013/10/01,950
2013/11/01,930
2013/12/01,540
2014/01/01,710
2014/02/01,340
2014/03/01,590
2014/04/01,890
2014/05/01,350
2014/06/01,790
2014/07/01,540
2014/08/01,250
2014/09/01,120
2014/10/01,600
2014/11/01,540
2014/12/01,230
2015/01/01,210
2015/02/01,920
2015/03/01,910
2015/04/01,770
2015/05/01,810
2015/06/01,220
2015/07/01,410
2015/08/01,890
];

You can use the following measure:

Sum({<Date = {'=Match(Year(Date),2014,2015)'}>} Sales)

And the line graph's first (group) dimension as Month(Date) and the line (second) dimension as Year(Date). It will give you this:

LineGraph.png

An easier way is to create the Year field in your script like below:

LOAD *, Year(Date) AS Year Inline [
Date,Sales
2012/12/02,400
2013/01/01,880
2013/02/01,90
2013/03/01,370
2013/04/01,910
2013/05/01,880
2013/06/01,220
2013/07/01,860
2013/08/01,930
2013/09/01,200
2013/10/01,950
2013/11/01,930
2013/12/01,540
2014/01/01,710
2014/02/01,340
2014/03/01,590
2014/04/01,890
2014/05/01,350
2014/06/01,790
2014/07/01,540
2014/08/01,250
2014/09/01,120
2014/10/01,600
2014/11/01,540
2014/12/01,230
2015/01/01,210
2015/02/01,920
2015/03/01,910
2015/04/01,770
2015/05/01,810
2015/06/01,220
2015/07/01,410
2015/08/01,890
];

Then your measure can be: Sum({<Year = {2014,2015}>} Sales)

Hope this helps.

Regards,

Mauritz