Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

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

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

jsimmonstx
Creator
Creator
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

jsimmonstx
Creator
Creator
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)';

jsimmonstx
Creator
Creator
Author

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

sunny_talwar

Error while reloading or when you used in your expression?

jsimmonstx
Creator
Creator
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?