Qlik Community

Ask a Question

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor
Contributor

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

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
Champion III
Champion III

Try this may be:

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

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

Contributor
Contributor

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

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

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)

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

Contributor
Contributor

Thank to everyone for trying to help me.

The answer of Sunny solve my problem.

Best regards