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: 
ziabobaz
Creator III
Creator III

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
Nicole-Smith

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

View solution in original post

4 Replies
Nicole-Smith

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

howiekrauth
Partner - Contributor III
Partner - Contributor III

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

ziabobaz
Creator III
Creator III
Author

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;

Nicole-Smith

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.