Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Don't miss the upcoming Q&A with Qlik session on Qlik Application Automation on November 16th! REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
manojkumargowda
Creator
Creator

Getfieldselections with multiple values in if condition

Hi,

I need to display logmonth only for the user selected Duemonths. Below expression works fine if one duemonth is selected, but when I select multiple values in duemonth, it doesn't work. Can you please suggest how to achieve this?

=if(logmonth=GetFieldSelections(DueMonth),logmonth)

1 Solution

Accepted Solutions
petter
Partner
Partner

This should work I think:

=If( Match( logmonth , $(=Chr(39) & GetFieldSelections(DueMonth,Chr(39)&','&Chr(39),12) & Chr(39) ) ), logmonth )

The entire expression between $( and the next to last ) will be evaluated and the result will be put into the outer expression verbatim and then the rest of the outer expression will be evaluated.

So if you have selected January, March and June in DueMonth this expression:

Chr(39) & GetFieldSelections(DueMonth), Chr(39) & ',' & Chr(39) , 12) & Chr(39)

will evaluate to this string:

'January','March','June'

and this will due to the $-sign expansion be put in so the outer expression will become:

=If( Match( logmonth , 'January','March','June' ), logmonth )

Which will return a true value (a positive number) if there are any matches.

View solution in original post

3 Replies
petter
Partner
Partner

This should work I think:

=If( Match( logmonth , $(=Chr(39) & GetFieldSelections(DueMonth,Chr(39)&','&Chr(39),12) & Chr(39) ) ), logmonth )

The entire expression between $( and the next to last ) will be evaluated and the result will be put into the outer expression verbatim and then the rest of the outer expression will be evaluated.

So if you have selected January, March and June in DueMonth this expression:

Chr(39) & GetFieldSelections(DueMonth), Chr(39) & ',' & Chr(39) , 12) & Chr(39)

will evaluate to this string:

'January','March','June'

and this will due to the $-sign expansion be put in so the outer expression will become:

=If( Match( logmonth , 'January','March','June' ), logmonth )

Which will return a true value (a positive number) if there are any matches.

View solution in original post

manojkumargowda
Creator
Creator
Author

Thanks Petter for the quick response and nice explanation.

In one more case, I'm trying to put same logic in SET Analysis. but it is not working, Can you please check what's wrong here.

sum({<logmonth=$(=Chr(39) & GetFieldSelections(DueMonth,Chr(39)&','&Chr(39),12) & Chr(39)) >}sales)

petter
Partner
Partner

Sum( {<logmonth= { $(=Chr(39) & GetFieldSelections(DueMonth,Chr(39)&','&Chr(39),12) & Chr(39) ) } >} Sales)