Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
vvira1316
Specialist II
Specialist II

Passing variable values from a QVW to another QVW and using it in that script

Hi,

I've a situation where I've to call another QVWs using execute script line.

Below is the script portion of Main QVW that is calling several other QVWs for execution. In script of other QVWs I've to use start (vS) and end (vE) dates used in Main Script for date range in selecting data within those called QVW scripts

let vScriptDirectory = '..\Scripts\';

let vS = '01/01/' & Year(Today());
let vE = If(Num(Month(MonthEnd(today(),-2))) < 9,  '0' & Num(Month(MonthEnd(today(),-2))), Num(Month(MonthEnd(today(),-2)))) & '/' &  Day(MonthEnd(today(),-2)) & '/' & Year(MonthEnd(today(),-2));

execute "C:\Program Files\QlikView\Qv.exe" /r /vvStart='$(vS)' /vvEnd='$(vE)' $(vScriptDirectory)FirstScript.qvw;
load 'FirstScript Completed.' as Log, now() as DtTm AutoGenerate 1;

execute "C:\Program Files\QlikView\Qv.exe" /r /vvStart='$(vS)' /vvEnd='$(vE)' $(vScriptDirectory)SecondScript.qvw;
load 'SecondScript Completed.' as Log, now() as DtTm AutoGenerate 1;

load 'Main Script Completed.' as Log, now() as DtTm AutoGenerate 1;
exit script;

Portion of called QVW script

DataTab:
LOAD
FIELD1 as F1,
FIELD2 as F2,
DATE_FIELD as DATE,
FROM

[saved.qvd]
(
qvd)
WHERE
[DATE_FIELD] >= '$(vStart)' and [DATE_FIELD]<= '$(vEnd)' ;  //these vStart and vEnd should use values that are available in vS and vE of calling QVW script.

Called scripts generates QVDs. Please advise what script modification is required in calling or called scripts to make this working or if any variables have to be defined in the called script.

Thanks,

Vijay

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

as already suggested by marcus, you can store your variable values (may be text or qvd) then you can use that in your other qvw. like

let vS = '01/01/' & Year(Today());
let vE = If(Num(Month(MonthEnd(today(),-2))) < 9,  '0' & Num(Month(MonthEnd(today(),-2))), Num(Month(MonthEnd(today(),-2)))) & '/' &  Day(MonthEnd(today(),-2)) & '/' & Year(MonthEnd(today(),-2));

Date_variable:
LOAD * Inline [
Startdate,EndDate
$(vS),$(vE)
]
;

STORE Date_variable into Date_variable.qvd(qvd);



.

.

.


Load your Date_variable table;

//use the peek statement here create the variable;


DataTab:
LOAD
FIELD1 as F1,
FIELD2 as F2,
DATE_FIELD as DATE,
FROM

[saved.qvd]
(
qvd)
WHERE
[DATE_FIELD] >= '$(vStart)' and [DATE_FIELD]<= '$(vEnd)' ; 

View solution in original post

4 Replies
marcus_sommer

If I have the need to share variables or parameters between various qvw's and also different programs I store them into txt-files as a variable-statement (quite rarely) and more often as simple parameter like run/stop/any date or within a table-structure - which you could easily read again in qlikview and other programs, too.

- Marcus

settu_periasamy
Master III
Master III

as already suggested by marcus, you can store your variable values (may be text or qvd) then you can use that in your other qvw. like

let vS = '01/01/' & Year(Today());
let vE = If(Num(Month(MonthEnd(today(),-2))) < 9,  '0' & Num(Month(MonthEnd(today(),-2))), Num(Month(MonthEnd(today(),-2)))) & '/' &  Day(MonthEnd(today(),-2)) & '/' & Year(MonthEnd(today(),-2));

Date_variable:
LOAD * Inline [
Startdate,EndDate
$(vS),$(vE)
]
;

STORE Date_variable into Date_variable.qvd(qvd);



.

.

.


Load your Date_variable table;

//use the peek statement here create the variable;


DataTab:
LOAD
FIELD1 as F1,
FIELD2 as F2,
DATE_FIELD as DATE,
FROM

[saved.qvd]
(
qvd)
WHERE
[DATE_FIELD] >= '$(vStart)' and [DATE_FIELD]<= '$(vEnd)' ; 

vvira1316
Specialist II
Specialist II
Author

Thank you Marcus

vvira1316
Specialist II
Specialist II
Author

Thank you Settu. Its working.