Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
scotthan
Partner - Contributor III
Partner - Contributor III

Determine if a value is currently selected?

Hi,

I am trying  to determine if a month is currently selected.  I am breaking an example down as much as possible to the point where the problem is.  See the expression:

match('ValueInQuestion',getFieldSelections(SampleField))

If I select ValueInQuestion as the only selection in the field SampleField, this function returns 1 as I would expect. However, if I select two values in the field SampleField, then I get 0 even if 'ValueInQuestion' is also selected. 

What is the proper way to do this?  More relevant to my situation, I am trying to determine if a certain month is selected, such that I can do match('Apr',getFieldSelections(Month)) and have that return some number that is > 0 when I have a bunch of months selected.

Thanks!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You should be able to use something like

=wildmatch(GetFieldSelections(FieldName),'*ValueInQuestion,*')

Remember that the GetFieldSelections() functions will only show a certain amount of values in clear text (use the third parameter to increase the number).

And I think there might be a more simple approach, too, but just can't get it right now.

Hope this helps,

Stefan

View solution in original post

5 Replies
swuehl
MVP
MVP

You should be able to use something like

=wildmatch(GetFieldSelections(FieldName),'*ValueInQuestion,*')

Remember that the GetFieldSelections() functions will only show a certain amount of values in clear text (use the third parameter to increase the number).

And I think there might be a more simple approach, too, but just can't get it right now.

Hope this helps,

Stefan

scotthan
Partner - Contributor III
Partner - Contributor III
Author

Thanks so much, I never thought to put the GetFieldSelections as the first parameter. Very creative!

My final expression is wildmatch(getFieldSelections(Month,','),'*'&Month(today())&'*')

dgreenberg
Luminary Alumni
Luminary Alumni

What if there could be two values:

I this example I am creating a field picker fro a report so I display a list of fields created by an inline table.

Then I build out the straight table chart and conditionally enable/disable the fields with an expression.

Topic

Sub Topic

Client Name

I want to check if Topic is selected but with your example if Sub Topic is selected it will also return a 1.

I have tried things like

=index(GetFieldSelections(%Fieldz2,'|',100),'Topic')

=wildmatch(GetFieldSelections(%Fieldz2,';',2000),'*Topic*')

=index(GetFieldSelections(%Fieldz2,'|',1000),'Topic')

So far the only thing I have working is ugly and that's to change it from Topic to Topic_ that therefore has a unique string.

Any suggestions?

dgreenberg
Luminary Alumni
Luminary Alumni

Far to often as soon as I type out a question I come up with the answer but still thankful the forum helps me do that.

This is how I resolved it.

Instead of

=wildmatch(GetFieldSelections(%Fieldz2,';',2000),'*Topic*')

I used

=wildmatch(GetFieldSelections(%Fieldz2,';',2000),'*;Topic;*') including the delineater ; before and after now only Topic returns a 1 Topic Group and Sub Topic do not.

dgreenberg
Luminary Alumni
Luminary Alumni

Actually I tweaked it some more as if it were the first or last value in the string it may not match.

Now I use this:

=wildmatch(('|' &concat(DISTINCT GetFieldSelections(%Fieldz2,'|')) &'|'),'*|Topic|*')