Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Make charts interact with selections

Hello all,

I have the next problem;

I want to make my chart more or less interact with the selection I make. When I select one year i want to show the values of that year, no problem because this is normal behaviour. When I select no year I want the data of a predefined year lets say 2010, and when i select multiple years I want the data of the selected year with the highest value. First i make the label;

=If(Len(GetFieldSelections(Year,';',1000))=0,
'2010',
Right(GetFieldSelections(Year,';',1000),4)
)

This works perfectly!

Then I make the definition;

If(Len(GetFieldSelections(Year,';',1000))=0,
Count({<Source={PTE},Year={2010}>}[Article number]),
Count({<Source={PTE},Year={Right(GetFieldSelections(Year,';',1000),4)}>}[Article number]
)

This doesn't work, the error is in the false section of the if statement, because when I replace this with 0 I get values when I make no selection;



If(Len(GetFieldSelections(Year,';',1000))=0,
Count ({<Source={PTE},Year={2010}>}[Article number]),
0
)

Can anyone help me out here? Thanks in advance!



1 Solution

Accepted Solutions
Not applicable
Author

Hello,

[[When I select no year I want the data of a predefined year lets say 2011]] For this Query, what you can do is go to the Properties of the Listbox and then under the General Tab select check box Always one selected Value (Before doing this you need to have 2011 selected). So no matter wherever you are always 2011 is selected and other selection of years anyways works normal.

ANDY

View solution in original post

5 Replies
Not applicable
Author

Hello,

[[When I select no year I want the data of a predefined year lets say 2011]] For this Query, what you can do is go to the Properties of the Listbox and then under the General Tab select check box Always one selected Value (Before doing this you need to have 2011 selected). So no matter wherever you are always 2011 is selected and other selection of years anyways works normal.

ANDY

Not applicable
Author

Indeed that's also a good one! And probably a solution in this case. I also want to know what I'm doing wrong in the solution I made because i can think of cases where I need this one. Thnx!

Not applicable
Author

Hello,

in your else-clause you are using SET Analysis within the count()-function. SET Analysis has another syntax as the if(). Try this when using SET:

. . . Year= { $(=maxstring(Year)) } . . .


Notes:

Maxstring() returns perfectly (what I think) what you want. Check it out in a textbox. To use a function within a SET Analysis-Clause you have to use the $(=) Operator. Please check the manual for details.

Hope this Helps

Roland

Not applicable
Author

This works! Thnx!Big Smile

Not applicable
Author

Hi again,

glad to help you. Would you mark my answer as solution so the thread will be marked green (solved).

RR