Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
paul_scotchford
Valued Contributor

Use a Variable as a Script line

Hi

I'm a newbie to QV (but not BI e.g. SSAS etc).

In my LOAD script I would like to set the value of a variable that has its definition stored in

a database.

Scenario:

We have a Business Dictionary in our DW (SQLServer 2012) and in it I will define a

variable called _vExecutable  it will be defined with a script line of let vCurrentYear = Lookup ('Year','Date_Key','$(zLastCompletePeriod)','CALENDAR');

Of course,If I hardcoded this in the LOAD Script it would be as let vCurrentYear = Lookup('Year','Date_Key','$(zLastCompletePeriod)','CALENDAR');

But as stated we dont want to do this except where absolutely necessary

Requirement:

I would like to substitute the LET statement with a Variable that defines _vCurrentYear , in a nutshell , execute variables as script lines

Can you see where Im heading with this ?

We dont want to hard code environment variables in the LOAD script, we want to utilise our dictionary

as much as possible as this is the one stop repository for business definitions and calculations (formulas)

Result:

I did test this using EXECUTE _vExecutable  but get a "Script Line Error" , the error window does imply something did actually work as I see a value embedded in the 'Date_Key' field.

Any feedback gratefully received, thanks in advance

Paul

(Brisbane, Qld)

1 Solution

Accepted Solutions

Re: Use a Variable as a Script line

EXECUTE statement is not appropriate here. If you have a variable that contains a valid script statement, the way to run that statement in the script is to type a script line that references the variable like this.

$(_vExecutable);

-Rob

2 Replies

Re: Use a Variable as a Script line

EXECUTE statement is not appropriate here. If you have a variable that contains a valid script statement, the way to run that statement in the script is to type a script line that references the variable like this.

$(_vExecutable);

-Rob

paul_scotchford
Valued Contributor

Re: Use a Variable as a Script line

Rob, Many thanks , this is exactly what we need.

Community Browser