Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variables with expressions in load script?

I have a variable defined in the document properties with the following value, which gets the value of the selected ReportName and is used in a show Condition.

=FIELDVALUE('ReportName',FieldIndex('ReportName',GetFieldSelections(ReportName)))

I tried to move this to the load script but it fails on the 'GetFieldSelections' function.

I read some other posts and it seems as though I need to do a set analysis but dont really understand how to actually do this.

Can anyone help me with this? Thanks.

Labels (1)
5 Replies
Not applicable
Author

How are you defining the variable in the Load Script?

If you use:

Let vVariable = FIELDVALUE('ReportName',FieldIndex('ReportName',GetFieldSelections(ReportName)))


It should give you the same result as if you defined the variable manually in document properties. "Let" is the key when you have a variable that is an expression and you don't want it to be evaluated at runtime.

Not applicable
Author

Yes,

Thats what I had. ReportName is a table built as inline and is defined before this variable. I dont know if that helps.

Here is the error I get when I try to 'reload' the script.

Error in expression:
GETFIELDSELECTIONS is not a valid function

Let vVariable = FIELDVALUE('ReportName',FieldIndex('ReportName',GetFieldSelections(ReportName)))



SET ThousandSep=','

Not applicable
Author

Try:

Set vVariable = "=FIELDVALUE('ReportName',FieldIndex('ReportName',GetFieldSelections(ReportName)))"


I think I misspoke about Let. It seems like you need to use Set here. Maybe Let does evaluate at run-time. Now I've confused myself. Big Smile

Not applicable
Author

That worked to get the variable set to the that string representation of the expression that I want. Now the question is, how do I get that expression to evaluate?

Thank you again for all your help. This is definitely appreciated.

Not applicable
Author

=vVariable as an expression. In some cases, you may need a dollar sign expansion: =$(vVariable)