Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

ziabobaz
Contributor II

multiple THEN in IF statement

Hi,

Quite a simple questions i think but i didn't find an answer.

in the load script is is correct to have one IF for multiple THEN?

Test:

NoConcatenate


Load

    if(status=6,1,0) as status,

    if(status=6,200,300) as revenue,

    if(status=6,'Y','N') as cancel_flag


RESIDENT MyTable;


Thank you!

1 Solution

Accepted Solutions

Re: multiple THEN in IF statement

What you have is fine.  You shouldn't receive any errors.

4 Replies

Re: multiple THEN in IF statement

What you have is fine.  You shouldn't receive any errors.

howiekrauth
New Contributor II

Re: multiple THEN in IF statement

Yes, this is correct.  This is done all the time.

ziabobaz
Contributor II

Re: multiple THEN in IF statement

Thanks, Nicole

There is one more

if I put

...

Resident table

where status=6;

does that mean that it first filters only those rows were status=6 and then use it for computation, meaning, I am loosing all other data and can't use PEAK function?

Example:

peak(status) as status // will always return '6', because the source table is filtered PRIOR to LOAD?

resident table

where status=6;

Re: multiple THEN in IF statement

Yes.  If you use the where clause, it will only pull in rows where the status is 6.  You will not have any other status numbers in your data.

Community Browser