Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem using variable in List Box expression.

Hi all,

I tried to find a solution in existing discussions but were not successful.


I have a ListBox defined containing years 2014, 2015, 2016.

If I use the following function:

= If(SubStringCount(GetFieldSelections(_year_listbox),'2014')=1,1,0)


the result is as expected, i.e. if the checkbox '2014' is marked I get a '1', of not a '0'.

Since I want to use the result, I want to set a variable to this '1' or '0' accordingly.

But if I change the expression to:


_definedvar = If(SubStringCount(GetFieldSelections(_year_listbox),'2014')=1,1,0)

the result is '1' if the 2014 checkbox is not selected and '0' if it is selected.

What needs to be done that the _definedvar is set to '0' or '1' depending on the 2014 checkbox?

Thanks a lot!

6 Replies
hic
Former Employee
Former Employee

What are you trying to do? What's the goal with having this in a variable? The reason I ask, is that I suspect there is a much simpler solution...

HIC

swuehl
MVP
MVP

Where / at what place do you change the expression to the above?

Please note that if you use something like above in a variable definition, it might render like you observe, since QV might interpret the equal sign as a comparison operator, not as an assignment operator.

It all depends on the context, so please give some more information.

maxgro
MVP
MVP

see attachment

hope it helps

Not applicable
Author

I do want to build a selection via this ListBox by which I can do select between one or more years (out of the defined list: 2014, 2015, 2016).

In other charts I want to use the variable in order to define a condition to switch on/of bars showing values of corresponding years.

The switching on/off I have implemented using different buttons and setting the variable within the action of these button. I now want to replace these buttons by checkboxes. therefore I switched to the approach using the ListBox.

Not applicable
Author

I want to use the variable in a condition of a bar chart (switching on/of bars of corresponding years).

Not applicable
Author

sorry - I am using the personal edition, so I cannot open this qvw file.