Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Variable in overview but returns null in dollar sign expansion

I am loading a table of variables with below. The number of rows is correct, and some variables work. All are seen in the variable overview with correct value. However, a few return null with dollar sign expansion in a text box.

Variables:
LOAD
Variable,
     Expression
    
FROM $(vQVDPath)VariablesQVD.qvd(qvd);

Let Rows = NoOfRows('Variables');
For i = 0 to NoOfRows('Variables')-1
Let vVariable=peek('Variable',$(i),'Variables');
Let '$(vVariable)' = peek('Expression',$(i),'Variables');
next i;
Tags (2)
1 Solution

Accepted Solutions
Not applicable

Re: Variable in overview but returns null in dollar sign expansion

I figured out the issue. When loading a variable from a spreadsheet and the value is text you have to use single quotes as well as the dollar sign expansion. ( ='$(vTabName') )

8 Replies
mgaseron
New Contributor II

Re: Variable in overview but returns null in dollar sign expansion

What looks to be causing the issue is the single quote around when defining $(vVariable) to its associated expression calculation. Remove them. Try the below:

LET Rows = NoOfRows('Variables');

FOR i=0 to $(Rows)-1

     LET vVariable = peek('Variable',$(i),'Variables');

     LET $(vVariable) = peek('Expression',$(i),'Variables');

NEXT

Re: Variable in overview but returns null in dollar sign expansion

Then the expressions in some of the variables will evaluate to null when you dollar-expand them in the context you use them in. Please post a qlikview document that demonstrates the problem.


talk is cheap, supply exceeds demand
princeanand61
New Contributor III

Re: Variable in overview but returns null in dollar sign expansion

Hiii Trey,

Use Set Statement in space of Let Statement If you want to use it in Text Box with Dollar Sign Exoansion.

Thanks & Regards

Prince Anand

Not applicable

Re: Variable in overview but returns null in dollar sign expansion

Have you removed = from before all expressions in Expression field in variables qvd file?

mgaseron
New Contributor II

Re: Variable in overview but returns null in dollar sign expansion

I agree with this statement...when defining the calculations in the Expression field, do not use the equal sign.

Employee
Employee

Re: Variable in overview but returns null in dollar sign expansion

The LET based variable means that the variable is evaluated during script reload. If you instead declared the variable as text it will not be evaluated during the reload. I think you could pull it of by using a SET declaration, alternatively by using Text().

SET '$(vVariable)' = $(=peek('Expression',$(i),'Variables'));

LET '$(vVariable)' = Text(peek('Expression',$(i),'Variables'));


Later when you want to refer the variable you simply dollar expand it into your expression(s).

Not applicable

Re: Variable in overview but returns null in dollar sign expansion

I figured out the issue. When loading a variable from a spreadsheet and the value is text you have to use single quotes as well as the dollar sign expansion. ( ='$(vTabName') )

Employee
Employee

Re: Variable in overview but returns null in dollar sign expansion

Good to hear you got it to work. Please remember to mark helpful and correct answers, to indicate that no more action is required on the thread and to give your fellow community member some thanks for helping out.

Community Browser