Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
qlik_j
Contributor
Contributor

Help: sub-categorise a field using multiple IF statement

Hi Everyone, 

 

I have a field as "Leave Type" which includes the following: 

Short Term Disability, Short Term Disability Not Approved,Short Term Disability Gradual Return to Work,Long Term Disability, Long Term Disability Gradual Return to Work,Long Term Disability Not Approved, Emergency Leave, Maternity Leave, Maternity  Short Term Disability, Parental Leave, Statutory Notice Leave, Personal Leave of Absence, Compassionate Family Medical Leave, Leave Other

I would like to categorize the above as follows: 

STD= Short Term Disability, Short Term Disability Not Approved,Short Term Disability Gradual Return to Work

LTD= Long Term Disability Gradual Return to Work,Long Term Disability Not Approved, Emergency Leave,

Maternity/Parental = Maternity Leave, Maternity  Short Term Disability, Parental Leave

Other= Statutory Notice Leave, Personal Leave of Absence, Compassionate Family Medical Leave, Leave Other

 

I would like to put this in a drill down stacked bar chart where once you click STD it will drill down to the sub categories.

What I wrote in the script is as follows: 

 If(WILDMATCH("Leave Type",'*Short*'), 'STD',
 If(WILDMATCH("Leave Type",'*Long*','*Emergency*'), 'LTD',
 If(WILDMATCH("Leave Type",'*Maternity*','*Parental*'), 'Maternity/Parental', 'Others'))) as Leave_Type2

This is not producing the correct results and I am getting a lot of null values.

I have attached a sample table as well

I appreciate your help on this. 

 


Test.PNG

Labels (5)
1 Reply
prabhu0505
Specialist
Specialist

You should take advantage of Applymap & Mapping table feature in Qlik

 

https://help.qlik.com/en-US/sense/November2019/Subsystems/Hub/Content/Sense_Hub/Scripting/MappingFun...