Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Nemo1
Creator II
Creator II

I want a graph that changes the years that displays (but not through filters)

Hello everyone!

I want to create a combo chart that would allow the user the following:

It would calculate the % of sales per store between two different years, and that would be shown as a line, and then as a bar it would show the year that the user chose. It can only show the most recent year.. 

so, the user should have the posibility to chose the two years in which he wants to see the difference between sales, and the most recent year would be displayed as a bar (because as far as i know only one bar can be displayed right?

 

so far i only have this formula, how do i like it to a filter? 

 

i really do not know how to make it such that 

( Sum({<Jahr = {CHOSEN YEAR?}>} Umsatz) - Sum({<Jahr = {CHOSEN YEAR}>} Umsatz) ) / Sum({<Jahr = {CHOSEN YEAR}>} Umsatz)

thanks.. i hope that i was clear!

Labels (4)
2 Replies
edwin
Master II
Master II

if there is no relationship between the two chosen years and you dont want the chosen years to affect the data set, then you can create 2 island tables with years in them.  you allow the user to choose 1 value per field from these two tables.

create 2 variables to store the two selections:
vCjhosenYear1=only([CHOSE YEAR 1])

vChosenYear2=only([CHOSE YEAR 2])

then your expression will be

( Sum({<Jahr = {$(vChosenYear1)}>} Umsatz) - Sum({<Jahr = {$(vChosenYear2)}>} Umsatz) ) / Sum({<Jahr = {$(vChosenYear2)}>} Umsatz)

 but ideally, you wouldnt allow the user to choose the same year twice, or 2nd year before the first (assuming the year 1 and year 2 is a range and the years dont have to be consecutive) so you would associate these two fields into one table where [CHOSEN YEAR 2] > [CHOSEN YEAR 1]

for example if YEAR is your field:

noconcatenate
tmpChooseYears:
load distinct
  YEAR as [CHOSEN YEAR 1]
resident
  YourTable;

inner join (tmpChosenYear)
load 
  [CHOSEN YEAR 2]
resident
  tmpChooseYears;

noconcatenate
ChooseYears:
load
  [CHOSEN YEAR 1],
  [CHOSEN YEAR 2]
resident
  tmpChooseYears
where
  [CHOSEN YEAR 2] >[CHOSEN YEAR 1];

drop table tmpChooseYears;

 

Nemo1
Creator II
Creator II
Author

Hello, thanks for answering.

I created the variables already... how can I apply them to a button?

I want to have two buttons, where the stakeholder can click and chose and years, and then those two bottons should affect my combo chart