1 Reply Latest reply: Sep 24, 2012 1:51 AM by Johannes Sunden RSS

    IF & Else condition

      need to clear the concepts of if & else condition. please provide directions.....

      application with script having if & else condition will be of a gr8 help.......................

        • Re: IF & Else condition
          Johannes Sunden

          Simple if function:

          if(condition , then , else)

          The three parameters condition, then and else are all expressions. The first one, condition, is interpreted logically. The two other ones, then and else, can be of any type. They should preferably be of the same type. If condition is true, the function returns the value of the expression then. If condition is false, the function returns the value of the expression else.


          if( Amount>= 0, 'OK', 'Alarm' )



          if..then..else..else if..end:

          The if..then control statement creates a conditional clause which makes the script execution to follow different paths depending on one or several logical conditions. The syntax is:

          if condition then

            [ statements ]

          { elseif condition then

            [ statements ] }

          [ else

            [ statements ] ]

          end if


          condition is a logical expression which can be evaluated as true or false.

          statements is any group of one or more QlikView script statements.

          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.


          if a=1 then

          load * from abc.csv;

          sql select e, f, g from tab1;

          end if


          if a=1 then; drop table xyz; end if;


          if x>0 then

          load * from pos.csv;

          elseif x<0 then

          load * from neg.csv;


          load * from zero.txt;

          end if