
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Set Analysis with Set Modifiers and Variables
Hello,
I am trying to use Set Modifiers within Set Analysis by using a variable. Very similar to the "Set Modifiers" portion of this thread. Set Analysis
Using the example below, I want to have 'West coast' and 'South America' replaced with a variable.
sum( <[Sales Region]={'West coast', 'South America'}>} sales)
where $(vExampleVariable) = 'West coast', 'South America' I want to use the following:
sum( {<[Sales Region]={$(vExampleVariable)}>} sales)
I have tried many different ways of writing the set analysis but can't seem to get the correct syntax.
- « Previous Replies
-
- 1
- 2
- Next Replies »
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is about Qlik Sense...
There is no variable support in Qlik Sense the same as in QlikView. You need extensions to use variables on the front end. I assume the problem here is the limitation of the extension.
So, instead of using a variable here, the full variable definition should be used in set:
sum( {<[Sales Region]={$(=chr(34) & concat(distinct [Field Name], chr(34)&','&chr(34)) & chr(34))}>} sales)
Tested, worked for me.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't see anything wrong with your last expression syntax. But the definition of the variable is not clear. I'd expect
vExampleVariable = 'West coast', 'South America'
To test - what you see in a text box with expression =vExampleVariable ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
in the script set the variable
SET vExampleVariable = 'West coast', 'South America';
and the expression is
sum( {<[Sales Region]={$(vExampleVariable)}>} sales)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Hanna,
I tried reproducing your situation and I think your error is in the definition of the variable, the comma should be included in the apostrophes:
$(vExampleVariable) = 'West coast, South America'

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The variable is not created in the script. I created the variable while editing the sheet.
The definition of the variable is Concat(DISTINCT [Field Name],',')
I have tried the following and none work properly.
Concat(DISTINCT [Field Name], ',')
Concat(DISTINCT '"'&[Field Name]&'"', ',')
Concat(DISTINCT [Field Name], ',')
Concat(DISTINCT chr(39)&[Field Name]&chr(39), ',')
I have a text box that shows me the value of $(vExampleVariable).
When I just put vExampleVariable in a text box, it does not return anything.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried this also, and it did not work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this
=chr(34) & concat(distinct [Field Name], chr(34)&','&chr(34)) & chr(34)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That did not work either.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just tried it with QlikView 12:.
LOAD * INLINE [
Region, Value
West coast, 1
South America, 2
Europe, 34
];
Textbox:
=sum({<Region ={$(var)}>} Value )
No problems:
Variable Overview:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try with Chr(39) instead of Chr(34)
=Chr(39) & Concat(DISTINCT [Field Name], Chr(39) & ',' & Chr(39)) & Chr(39)

- « Previous Replies
-
- 1
- 2
- Next Replies »