Search code examples
qlikviewqliksense

Assign multiple string to a single variable


I have a button which when clicked assigns values to a variable which is used for filtering within other charts. It works fine when i only assign one value but when i try to assign 2 values to the same variable it doesn't produce any data.

The button action is 'Set a variable value'

The variable is called: vCompany

Within the value box i have tried:

='Go Web'&','&'Go Call'
='Go Web'&,&'Go Call'
=ValueList('Go Web'&','&'Go Call')
=ValueList('Go Web'&,&'Go Call')
=Concatenate('Go Web'&','&'Go Call')

Nothing i try works. I just want 2 values in one variale so when i use later on eg =Count(DISTINCT {<COMPANYNAME={'$(vCompany)'}Staff) it produces figures for both companies.

Anyone able to shed any light?

Thanks in advance


Solution

  • Problem is that you need to encode slashes and comma as ascii character, as without it they are implemented as part of variable (for example string opening). So code in your button should be:

    =chr(39) & 'Go Web' & chr(39) & chr(44) & chr(39) & 'Go Call' & chr(39)
    

    then your expression can be:

    =Sum( {$< COMPANYNAME={$(vCompany)} >} Staff)