Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QLIKWORLD LIVE! MAY 16 - 19TH, EARLY BIRD DISCOUNTS! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
paul_scotchford
Specialist
Specialist

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
rwunderlich

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

View solution in original post

2 Replies
rwunderlich

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
Specialist
Specialist
Author

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