Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
If you are a Qlik Insight Bot user, join this collaborative group: JOIN GROUP
Not applicable

load variable from outside

I load  many variables  from .xls  into QVW . But I can't load the following :

   sum({<year={"$(=left(saledate,4)-1)"}>} sales)

after loading , it became :   sum({<year={''}>} sales)

if I set it in QVW ,it is ok , How to do it  ?

Tags (1)
9 Replies
Highlighted
MVP
MVP

Re: load variable from outside

How do you load your variables from .xls? How does your current script look like?

Highlighted
Not applicable

Re: load variable from outside

it is like the following :

VariablesTable:
LOAD VariableName,
     VariableValue
FROM
[QVDStore\VariablesTable.QVD]
(qvd); or xls
//* Set Equation variables
//* The following loop allowing for loading numerous variables dynamically,
//* without having to call them by name.
for i=0 to noofrows('VariablesTable')-1
  LET var_name= peek('VariableName',i,'VariablesTable');
  LET $(var_name) = peek('VariableValue',i,'VariablesTable');
  TRACE Load Variable: $(var_name) = $($(var_name));
next i

all variables seem ok . but for like this kind of  '=..' is not ok .

Highlighted
MVP
MVP

Re: load variable from outside

Let vNumberOfRows = NoOfRows('VariablesTable');

For i = 0 to (vNumberOfRows - 1)

     Let vVariable_Name = Peek('VariableName',i,'VariableTable');

     Let [$(vVariable_Name)] = Peek('VariableValue',I,'VariableTable');

Next

Highlighted
Not applicable

Re: load variable from outside

my script is : for i=0 to noofrows('VariablesTable')-1   LET var_name= peek('VariableName',i,'VariablesTable');   LET $(var_name) = peek('VariableValue',i,'VariablesTable'); //  TRACE Load Variable:   let $(var_name) =' $($(var_name))'; next i I thinks the problem is '=' in variables ,It seem calcault it before .

Highlighted
MVP
MVP

Re: load variable from outside

How you have stored Varaible Expression / Values in Excel File?

You have to store like

SUM(Value)

Not like

=SUM(Value)

Highlighted
MVP
MVP

Re: load variable from outside

Consider that your expression is something like below...

only(  {$<Year={"$(=max(Year))"}>} Year)

If you Trace this expression during Reload $(=Max(Year)) will be shown as blank as during loading no Year is selected.

May be I am not able to explain the exact technical information....

Highlighted
Not applicable

Re: load variable from outside

  let $(var_name) =' $($(var_name))---- this is wrong for your kind of expresion, I must use   :TRACE Load Variable: $(var_name) = $($(var_name));  it is ok now . I can't explan it also. thanks your help ;

Highlighted
MVP
MVP

Re: load variable from outside

Yes, I also think it's just a problem with your TRACE statement, where the dollar sign expansion in your expression you  evaluate in your variable won't work.

So you should have got the correct variables build right from the start, when looking in the variable overview after load, right?

Highlighted
Not applicable

Re: load variable from outside

YES ,IT is OK now  use trace load .