Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Join us for a live Q&A! September 21, 10 AM ET - Onboarding Fast in Qlik Sense SaaS! REGISTER
Showing results for 
Search instead for 
Did you mean: 

Putting a Set Analysis Expression into a Variable

How do I make a double-quoted string expand properly in a variable?

I have this:

SET vFieldName = ComplianceStatus;
SET vFieldCount = (GetSelectedCount($(vFieldName)) + GetAlternativeCount($(vFieldName)));
SET vSelectAllOrNone = GetSelectedCount($(vFieldName))=0 OR GetSelectedCount($(vFieldName))=$(vFieldCount);
SET vSubSelectColor1 = ONLY({<CompName={"$(=TRIM(SUBFIELD(GetFieldSelections($(vFieldName)),',',1)))"
} >} CompColor);

Then, I have this:

SET vColor1 = IF($(vSelectAllOrNone), CompColor1, $(vSubSelectColor1));

The variable vSubSelectColor1 looks like this when I inspect it:

ONLY({<CompName={""} >} CompColor)

In vColor1, I'm expecting it to look like it does as I defined it. How do I make that happen?

10 Replies

Variable Overview shows this value for vSubSelectColor1 after a reload:

ONLY({<CompName={""} >} CompColor)

With your changes, after a reload, I get a script line error on the line, and Variable Overview shows this:


I tried replacing the single quotes with chr(39), and Variable Overview shows this:

ONLY({<KeyValue={"$(=TRIM(SUBFIELD(GetFieldSelections($(vFieldName)),',',1)))"} >} KeyColor)

think I've got it figured out - I ALSO had to break the variable declaration up as you indicated on vColor1, like so:

LET vDimColor1 = 'IF($' & '(vSelectAllOrNone), KeyColor1, $' & '(vSubSelectColor1))';

Now, for the calculated color, the expression consists of this:


After FOUR full days of work, it finally seems to work as intended.