Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I was just trying to understand the usage of control statements in qlikview and wrote the below code:
let var1=0;
let var2=0;
//sub a
FOR i = 0 to 10
var1=$(var1)+1;
trace $(var1);
NEXT i
//end sub
var2=0+1;
trace $(var2);
This code works as expected but when i uncomment the statements sub a and end sub I get var1=0 and var2=1.
Could someone please let me know whats the logic here, also please advice how i could gain more understanding on these aspects apart from help file.
Attached is the qlikview for reference
The subroutine has to be called upon from a call statement. Use call a; at the end. PFA the app for your reference.
Regards
Pratyush
Seems, You are not calling Sub function at the end. It should be like below
let var1=0;
let var2=0;
sub a
FOR i = 0 to 10
var1=$(var1)+1;
trace $(var1);
NEXT i
end sub
var2=0+1;
trace $(var2);
call a