Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Amelia_96
Contributor III
Contributor III

If..Else if function does not working

Hi, i am very new to Qlik View and i'm trying to use if..else if function to create new field. but it seems to have an error. 

Can anyone tell me what's wrong with this code?

AA2:
Load *, RowNo() as NO,
(If strwarncd='M014' then 'Income';
else if strwarncd = 'M003' then 'LIAM';
else if strwarncd = 'M015' then 'Financial';
else if strwarncd = 'M030' then 'Declaration';
else if strwarncd in ('auto09', 'M001') then 'Above NML';
else if strwarncd = 'M002' then 'Occupation';
else if strwarncd = 'eBMI' then 'BMI';
else if strwarncd = 'Err06' then 'Nationality';
else if not isnull(strwarncd) then 'Others';
END IF) as Category;
resident table AA;

Thank you in advance!!

4 Replies
manmadha
Contributor III
Contributor III

Dear Expert,
Try This one,
Load *, RowNo() as NO,
If(strwarncd='M014','Income',
if(strwarncd = 'M003','LIAM',
if(strwarncd = 'M015','Financial',
if(strwarncd = 'M030','Declaration',
if(strwarncd = wildmatch('auto09', 'M001'),'Above NML',
if(strwarncd = 'M002','Occupation',
if(strwarncd = 'eBMI','BMI',
if(strwarncd = 'Err06','Nationality','Others') Category
resident table AA;
MayilVahanan

HI @Amelia_96 

Try This one,
Load *, RowNo() as NO,
If(strwarncd='M014','Income',
if(strwarncd = 'M003','LIAM',
if(strwarncd = 'M015','Financial',
if(strwarncd = 'M030','Declaration',
if(match(strwarncd ,'auto09', 'M001'),'Above NML',
if(strwarncd = 'M002','Occupation',
if(strwarncd = 'eBMI','BMI',
if(strwarncd = 'Err06','Nationality','Others')))))))) as Category
resident table AA;

Note that, then is not required here. Need to close the brackets correctly.

Or 
Try with Pick & Match function combination, its easy way, like

Sample:
Pick(Match(strwarncd,'M014','M003')+1, 'Others', 'Income', 'LAM') as Category

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Amelia_96
Contributor III
Contributor III
Author

Thank you. This works well

Amelia_96
Contributor III
Contributor III
Author

Thank you.. This works well too