Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Anonymous
Not applicable
Author

Anonymous
Not applicable
Author

If it is, it is unclear how to resolve it.

neelamsaroha157
Specialist II
Specialist II

Does vFieldname returns multiple values?

Your expression works if you have one of the value selected in a field.

Capture.PNGCapture1.PNG

Anonymous
Not applicable
Author

No - vFieldName is simply a way to generalize the code so it can be re-used elsewhere with little modification. It returns the one value I assigned to it (the name of the field in question).

sunny_talwar

I think the issue is with the expansion of the dollar sign expansion

Expression as a variable with $-sign expansion

LET vSubSelectColor1 = 'Only({<CompName={"$' & '(=TRIM(SUBFIELD(GetFieldSelections($' & '(vFieldName)),',',1)))"}>} CompColor)';

Anonymous
Not applicable
Author

That resulted in the error " Garbage after expression 's' "

sunny_talwar

Error while reloading or when you used in your expression?

Anonymous
Not applicable
Author

I'm displaying the expression in a text object. When I reload, the text object displays that error message instead of the expression.

sunny_talwar

can you see what the variable definition is after the reload is completed in the variable overview? Can you share an image of variable overview?