6 Replies Latest reply: Jul 3, 2017 11:27 AM by Francesco Bresciani

# nested variables

Hi everybody,

it's my first post on this community.

I have defined 2 variables (var1,var2). The first variable is an expression of fields extracts from my LOAD and it works well. var1 = Sum([Field1])+Sum(Field2])

The second var is an expression of my first var (var1) and some fields extracts from my LOAD. In this case my expression returns null, because it looks like it not evaluate my first var. var2 = \$(var1) + sum([Field3])

How can i use a var in the expression of another var?

Best regards

• ###### Re: nested variables

Try this may be:

SET vFlag  =  = Sum(Field1) + Sum(Field2);

SET vFinal =  = \$(vFlag) + Sum(Field3);

• ###### Re: nested variables

I attach the image of my problem:

The column [expression] is made by this expression:

=(\$(Qtà 1 Lvl DiBa)*[Qtà 2° Livello])+(\$(Qtà 1 Lvl DiBa)*(if(isnull([Sfrido % Medio]),0,[Sfrido % Medio]))/100)

The column [variables] is made by this expression:

=\$(Qtà 2 Lvl DiBa)

In my sheet i have defined in "view variables..."

The expression of the column [expression] (marked green) is the same expression defined in the variable [Qtà 2 Lvl DiBa] set in the column [variables]

My question is: why the result of column [variables] is "-" (null) and in the result of column [expression] is correct?

I hope i have explained the situation.

• ###### Re: nested variables

Try to remove this equal sign here

or if you want to use the equal sign, try to use your variable without a dollar sign expansion and see if that helps you resolve your issue.

• ###### Re: nested variables

Thank to everyone for trying to help me.

The answer of Sunny solve my problem.

Best regards

• ###### Re: nested variables

Can you try using quotes around your variables and try? If not could you please upload this sample to work on it quickly?

Like: Can you try this

= ('\$(Qtà 1 Lvl DiBa)' * [Qtà 2° Livello])+ ( '\$(Qtà 1 Lvl DiBa)'  *  (if(isnull([Sfrido % Medio]),0,[Sfrido % Medio]))/100)

• ###### Re: nested variables

Hi Francesco,

You could try RangeSum( \$(var1) , sum([Field3])) instead of ' + '. Rangesum treats a non numeric or a null argument as a zero rather than throwing an error like '+'. Maybe that will solve the problem.

Cheers

Andrew