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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Flipflop
Contributor III
Contributor III

GetFieldSelections syntax with if condition in chart expression

Hi,

I don't understand the result of GetFieldSelections when there are mutliple values in chart expression, i try this :

if(GetFieldSelections([SOURCE])=Chr(39)&'VALUE1'&','&'VALUE2'&Chr(39),1,0)

or

if(GetFieldSelections([SOURCE])='VALUE1,VALUE2',1,0)

but it's not working. VALUE1 and VALUE2 are selected in a filter SOURCE, and the if is working when only 1 value is selected.

What's my error ?

Labels (3)
1 Solution

Accepted Solutions
vincent_ardiet_
Specialist
Specialist

Like this (with a space)  if(GetFieldSelections([SOURCE])='VALUE1, VALUE2',1,0)
Or you specify the separator   if(GetFieldSelections([SOURCE],',')='VALUE1,VALUE2',1,0)

View solution in original post

4 Replies
vincent_ardiet_
Specialist
Specialist

There are other ways to write this using set analysis as, by default, after 6 values selected you will obtain a result like "7 of 22" (if you have 22 different values).
For example, if you want to test if VALUE1 and VALUE2 are the only selected value:
Count(Distinct {<SOURCE/={'VALUE1 ','VALUE2'}>}SOURCE)=0

Flipflop
Contributor III
Contributor III
Author

Ok, but i have not this issue because i have only 4 values. And there are no other filters with the same field.

And in the Qlik's documentation, the result of GetFieldSelections in this case is 'VALUE1,VALUE2'.

So, is it a syntax issue ?

vincent_ardiet_
Specialist
Specialist

Like this (with a space)  if(GetFieldSelections([SOURCE])='VALUE1, VALUE2',1,0)
Or you specify the separator   if(GetFieldSelections([SOURCE],',')='VALUE1,VALUE2',1,0)

Flipflop
Contributor III
Contributor III
Author

The space... It's working now, thank you so much !