# New to Qlik Sense

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

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save \$300 before February 6: REGISTER NOW!
cancel
Showing results for
Did you mean:
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
Partner - Champion III

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.

3 Replies
Partner - Champion III

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.

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)

Partner - Champion III

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

Tags
Community Browser