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: 
Not applicable

Variable inside a variable in the load script

hi all,

I have a variable which works fine when added manually to Settings > Variable Overview but does not work when loaded in from a text file via the load script.

Here is the expression:-

=if(isnull(GetFieldSelections(Metric_List)) or wildmatch(GetFieldSelections(Metric_List),'Customer Count'),

num(sum({<CA={'1'} >} CUS),'###########,###'),

num((sum({<CA={'1'} >} $(vMetric_Percent))/sum({<CA={'1'} >} CUS)),'#,##0.##%'))

The variable reference is vMetric_Percent which has this value inside it =MetricLookup.

When I try to load this expression from a text file unchanged instead of $(vMetric_Percent) it has been evaluated as =MetricLookup and therefore does not work.

Is there any way to get around this problem?

Thanks

Stuart

4 Replies
Anil_Babu_Samineni

Can you check this in Text object and see whether the value is coming up over there?

=$(vMetric_Percent)


And then, What you have written for Variable and where do you written(I mean Variable overview / Script)

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Peter_Cammaert
Partner - Champion III
Partner - Champion III

You're in need of something you could call "Delayed expansion". Meaning that the embedded $-sign construct should be expanded when the expression is evaluated (in a UI object), not when the text is assigned to the expression variable.

There are a number of techniques for avoiding this effect. Sunny has already shown a few. Here are some others:

  1. An assignment using a LET statement has expansion of embedded $-sign constructs blocked, as soon as even a single space is put between the $-sign and the opening bracket. Usually this means you've got to glue together pieces of a string, like:
            LET vExpression = '=count({<$' & '(vSetSpec)>} LineFlag)';
  2. If you use variables (i.e. not strings) to pass around your expressions, no substitution will be performed as the Script engine will only perform substitution on script content, never on variable content

Best,

Peter