Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bmac1
Partner - Contributor II
Partner - Contributor II

List of Field Selections for use in Set Analysis

Hi,

Currently, in my set analysis, I have the field selection hardcoded -->

ex: [STATE]={'NJ', 'MA', 'CA'}

I need to turn this into a variable because I want the selections to be different based on a condition.

However, when I try to create a variable 

vState_Group1  = {'NJ', 'MA', 'CA'}

I get, missing "}". I've tried writing the expression with and without the equal sign.

 

Thanks.

Labels (4)
6 Replies
WaltShpuntoff
Employee
Employee

The set analysis sytax requires the {}

If you change vState_Group1 = 'NJ', 'MA', 'CA'

That would make your set expression using the variable look more like this:

{$(vState_Group1)}

 

-ws

Lisa_P
Employee
Employee

Can you describe more details about your conditions because there are ways to allow selections to apply in Set Analysis

bmac1
Partner - Contributor II
Partner - Contributor II
Author

thanks. still results in an error though, garbage after expression ","

MeehyeOh
Partner - Creator
Partner - Creator

Hi @bmac1 

Try this 

-Variable 

Name : vState_Group1
Definition : =Replace('NJ,MA,CA', ',', Chr(39)&','&Chr(39))

And in  set analysis use variable with a single quote!

 

Please reply! thanks!

marcus_sommer

Commas within a variable will be treated as a parameter-delimiter and not as variable-content. In your case you could avoid the commas by using another set analysis syntax like:

vState_Group1 = (NJ|MA|CA)

Beside this it's much easier to use field-selections instead of variables, for example:

< Field = p(Field) >

or if not the origin field should be used for the selections a second independent field from an island-table might be applied, like:

< Field = p(MyIslandField) >

 

WaltShpuntoff
Employee
Employee

Open the offending expression in the edit window and look at the preview at the bottom of the screen. If you cannot see what is wrong with it in the preview, then  post a screen clip of it.

-ws