Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to write multiple if conditions

i should write multiple if conditions how can i write them syntax please

7 Replies
dmohanty
Partner - Specialist
Partner - Specialist

Hi,

You have to use the IF...THEN statement like a conditional clause to follow different paths. Below is an example:

IF a>0 then

load * from A.qvd (qvd);

ELSEIF a<0 THEN

load * from B.qvd (qvd);

ELSE

load * from C.qvd (qvd);

END IF

alexandros17
Partner - Champion III
Partner - Champion III

if(cond1,v1,

if(cond2,v2

if(cond3,v3,

     v4

)

)

)

manideep78
Partner - Specialist
Partner - Specialist

Hi,

syntax: If(<Condition>, <true>,<False>)

you can write if condition inside if statement.

see below example

=If (Average>=75, 'Distinction',  If (Average>=60, 'Firs Class', If(Average>=50,'Second Class','fail')))

for more information see help in qlikview. topic: If..then..elseif..else..end if

You can also refer in qlikview reference manual.

jagan
Luminary Alumni
Luminary Alumni

Hi,

You can also try Match() and Pick() functions.

pick(n, expr1[ , expr2,...exprN])

match( str, expr1 [ , expr2,...exprN ] )

Hope it helps you.

Regards,

Jagan.

Not applicable
Author

Hi

Please, can you help me, it is very urgent!!!!

I have a same problem with if conditions how can i write this :
for exemple :

  CASE (D.DOC_TYPE)WHEN 'A' THEN 'Achat'

    WHEN 'V' THEN 'Ventes'

    END AS 'Type de doc.',

       

  CASE (D.DOC_TYPE)

    WHEN 'V'

            THEN

                CASE (D.DOC_STYPE)

                        WHEN 'P' THEN 'Pro-forma'

                        WHEN 'D' THEN 'Devis'

    END

    WHEN 'A' THEN

        CASE (D.DOC_STYPE)

            WHEN 'D' THEN 'Demandes de Prix'

            WHEN 'C' THEN 'Commandes'

            WHEN 'B' THEN 'Bons de Réceptions'

        END

    END AS 'Sous type de doc.',

Regards.

manideep78
Partner - Specialist
Partner - Specialist

Try like this:

if(D.DOC_TYPE ='A','Achat',

       if(D.DOC_TYPE ='V','Ventes')) as [Type de doc]

if(D.DOC_TYPE='V',

      if(D.DOC_STYPE='P',''Pro-forma','Devis'),

              if(D.DOC_TYPE='A',if(D.DOC_STYPE='D','Demandes de Prix',

                        if(D.DOC_STYPE='C','Commandes',

                                     if(D.DOC_STYPE='B', 'Bons de Réceptions'))))) as [Sous type de doc]


I hope this helps you.

Cheers!

Regards,

Manideep

its_anandrjs

Hi,

From QV Help which is nested if condition

if condition then

  [ statements ]

{ elseif condition then

  [ statements ] }

[ else

  [ statements ] ]


Examples:

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;

else

load * from zero.txt;

end if

Regards

Anand