Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Leverage your QlikView investment to modernize BI – see how! Join Group
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

how to write multiple if conditions

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

7 Replies
Highlighted
Partner
Partner

Re: how to write multiple if conditions

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

Highlighted

Re: how to write multiple if conditions

if(cond1,v1,

if(cond2,v2

if(cond3,v3,

     v4

)

)

)

Highlighted
Partner
Partner

Re: how to write multiple if conditions

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.

Highlighted
MVP & Luminary
MVP & Luminary

Re: how to write multiple if conditions

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.

Highlighted
Not applicable

Re: how to write multiple if conditions

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.

Highlighted
Partner
Partner

Re: how to write multiple if conditions

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

Highlighted

Re: how to write multiple if conditions

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