Skip to main content Skip to complementary content

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:  

If 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

Learn more

 

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!

Join the Analytics Modernization Program

Remove banner from view

Modernize without compromising your valuable QlikView apps with the Analytics Modernization Program. Click here for more information or reach out: ampquestions@qlik.com