Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Multiple lines in a line graph

Hi,

I have created one line graph by week for the amount of Cigarette Sales. I have a requirement to plot the graph in such a way so that it plots for the weeks of the current year and also plots another line for the same weeks of previous year. So, that we can have a current year vs last year comparison. My dimension is weeknumber and my expression uses avg(cigarette_sales). My Current year is 2012 and my previous year is 2011. Week is a field defined according to my calender.

Any ideas how to accomplish this? I would necessarily need 2 Line graphs to be displayed for 2 years in a single Line chart.

All help would be highly appreciated.

Thanks,

Tutan

1 Solution

Accepted Solutions
manisha_uit
Creator
Creator

Hi Tutan,

As told by Johannes, you will have to create two different expressions if you want to have two lines in your chart.

I have attached a sample file.

That might help you

Thanks

Manisha

View solution in original post

6 Replies
Anonymous
Not applicable
Author

avg(cigarette_sales) shows the average per week for your current selection.

For 2012 you can use:

avg({$<Year={2012}>} cigarette_sales)

or

avg({$<Year={$(=Year(Today()))}>} cigarette_sales)

For 2011 you can use:

avg({$<Year={2011}>} cigarette_sales)

or

avg({$<Year={$(=Year(addmonths(Today(),-12)))}>} cigarette_sales)

or

avg({$<Year={$(=Year(Today())-1)}>} cigarette_sales)

Might have missed a character here or there in my untested set anaysis

Not applicable
Author

HI Johannes,

I have done that already, but this only plots one graph in the Line chart. i.e. when I select Year as 2011 in the Year list box, it plots for 2011. Similarly for 2012. So, I have 2 line graphs which are seperate. I want both the line graphs together in one single chart, may be one displaying in green, the other in red.

So, my X-Axis has Week numbers

Y Axis has the Sales figures

I should have 2 graphs plotted between these 2 axes for current year and previous year.

Hope this clarifies.

Thanks,

Tutan

Anonymous
Not applicable
Author

Tutan,

For two lines in a line chart you create two expressions.

Not sure if I'm missing something here. Maybe you can attach an example app?

manisha_uit
Creator
Creator

Hi Tutan,

As told by Johannes, you will have to create two different expressions if you want to have two lines in your chart.

I have attached a sample file.

That might help you

Thanks

Manisha

Not applicable
Author

Any chance a new qvw file for solution can be added that allows me to open in personal edition of Qlikview

Not applicable
Author

Personal edition can only open files you've created yourself. It can't be used to open any file made by someone else.