Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!!
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
Thank you. This works well
Thank you.. This works well too