Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone!
I'm new to QLIK and I need to use a list of strings in many chart formulas (including some long nested IF statements) and so I want to assign it to a variable if I can. I'm not sure how to do this.
As an example, this is what I am currently using in one of my charts to exclude products from certain countries in a dataset -
Count({$<company_location -= {'U.S.A', 'France', 'Canada', 'U.k.'}>} counts_of_products)
What I would like to do -
country_list = 'U.S.A', 'France', 'Canada', 'U.k.'
Count({$<company_location -= {country_list}>} counts_of_products)
so that I can reuse the country_list for other charts instead of typing the list every time. Is this possible?
I'd really appreciate any help, thanks!
Hi
You can create variables by selecting the variable button in edit mode (highlighted below)
Create new variable vCountryList = {'United States','France','United Kingdom'}
Then it can be used in set analysis as in the example below:
count(distinct
{<
[Country - Placement] =$(vCountryList)
>}PlacementId)
The dollar expansion $ executes the code in the variable to bring back the desired countries
Hope this helps!
Hi
You can create variables by selecting the variable button in edit mode (highlighted below)
Create new variable vCountryList = {'United States','France','United Kingdom'}
Then it can be used in set analysis as in the example below:
count(distinct
{<
[Country - Placement] =$(vCountryList)
>}PlacementId)
The dollar expansion $ executes the code in the variable to bring back the desired countries
Hope this helps!
Hey, thanks for the reply!
When I tried to create the list you said, I get an error -
={'U.S.A','France','Canada'}
Error in expression: '}' expected
Any advice with this?
Remove the =
It should look like this in the variable list 🙂
Works perfectly, thanks a lot! 🙂