Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
frinfo
Partner - Contributor II
Partner - Contributor II

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

1 Solution

Accepted Solutions
sunny_talwar

Try to remove this equal sign here

Capture.PNG

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.

View solution in original post

6 Replies
vishsaggi
Champion III
Champion III

Try this may be:

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

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

frinfo
Partner - Contributor II
Partner - Contributor II
Author

I attach the image of my problem:

view.png

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..."

variable1.png

variable2.png

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.

Thank you in advance

sunny_talwar

Try to remove this equal sign here

Capture.PNG

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.

vishsaggi
Champion III
Champion III

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)

effinty2112
Master
Master

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

frinfo
Partner - Contributor II
Partner - Contributor II
Author

Thank to everyone for trying to help me.

The answer of Sunny solve my problem.

Best regards