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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
curiousfellow
Specialist
Specialist

two values in variable to use in set analysis

I have records that can have two conditions I or V

I have a listbox with three choices : 

I

V

I and V

I store the choice in a variable that I want to use in set analysis

First two choices are easy 🙂 but how do I have to store the third option so I can use it in set analysis.

I tried something like Vchoice= 'V|I' but  that does not work

1 Solution

Accepted Solutions
edwin
Master II
Master II

using Field={'I','V'} will bring up any rows with either of these two values some with only I and some with only V.  to get both this is one way:

{<Field=p({<IVField={'V'}>}Field)>*<Field=p({<IVField={'I'}>}Field)>}  this ensures only one with both I and V

so you can create 2 variables one for I and one for V (driven by selection):
vI if selection = I or I and V  '{' & chr(39) & 'I' & chr(39) & '}'

vV if selection = V or I and V'{' & chr(39) & 'V' & chr(39) & '}'

and you expression will be:
{<Field=p({<IVField=$(vV)>}Field)>*<Field=p({<IVField=$(vI)>}Field)>} 

if user selects the third option both variables should be set, i user only select 1, the other should be set to empty string which is evaluated as:

{<Field=p({<IVField={'I'}>}Field)>*<Field=p({<IVField=>}Field)>}  if user selects only I.

View solution in original post

2 Replies
Kushal_Chawda

@curiousfellow  try below expression in variable

=concat(distinct chr(39) & listboxfield & chr(39), ',')

edwin
Master II
Master II

using Field={'I','V'} will bring up any rows with either of these two values some with only I and some with only V.  to get both this is one way:

{<Field=p({<IVField={'V'}>}Field)>*<Field=p({<IVField={'I'}>}Field)>}  this ensures only one with both I and V

so you can create 2 variables one for I and one for V (driven by selection):
vI if selection = I or I and V  '{' & chr(39) & 'I' & chr(39) & '}'

vV if selection = V or I and V'{' & chr(39) & 'V' & chr(39) & '}'

and you expression will be:
{<Field=p({<IVField=$(vV)>}Field)>*<Field=p({<IVField=$(vI)>}Field)>} 

if user selects the third option both variables should be set, i user only select 1, the other should be set to empty string which is evaluated as:

{<Field=p({<IVField={'I'}>}Field)>*<Field=p({<IVField=>}Field)>}  if user selects only I.