Skip to main content
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)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
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