Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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.
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 ?
in the script set the variable
SET vExampleVariable = 'West coast', 'South America';
and the expression is
sum( {<[Sales Region]={$(vExampleVariable)}>} sales)
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'
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.
I tried this also, and it did not work.
Try this
=chr(34) & concat(distinct [Field Name], chr(34)&','&chr(34)) & chr(34)
That did not work either.
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:
Try with Chr(39) instead of Chr(34)
=Chr(39) & Concat(DISTINCT [Field Name], Chr(39) & ',' & Chr(39)) & Chr(39)