If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.
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)
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.
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.
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)
Sum( {<logmonth= { $(=Chr(39) & GetFieldSelections(DueMonth,Chr(39)&','&Chr(39),12) & Chr(39) ) } >} Sales)