If..then..elseif..else..end if
The if..then control statement is a script selection construct forcing the script execution to follow different paths depending on one or several logical conditions.
Control statements are typically used to control the flow of the script execution. In a chart expression, use the if conditional function instead. For more information see if - script and chart function.
Syntax:
If condition then
[ statements ]
{ elseif condition then
[ statements ] }
[ else
[ statements ] ]
end if
Since the if..then statement is a control statement and as such is ended with either a semicolon or end-of-line, each of its four possible clauses (if..then, elseif..then, else and end if) must not cross a line boundary.
Arguments:
Argument | Description |
---|---|
condition | A logical expression which can be evaluated as True or False. |
statements | Any group of one or more QlikView script statements. |
Example 1:
if a=1 then
LOAD * from abc.csv;
SQL SELECT e, f, g from tab1;
end if
Example 2:
if a=1 then; drop table xyz; end if;
Example 3:
if x>0 then
LOAD * from pos.csv;
elseif x<0 then
LOAD * from neg.csv;
else
LOAD * from zero.txt;
end if