Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ruma_barman
Creator
Creator

Multiple if statement with "or" and "and"

Hi All,

My requirement is to create a field and categorize into 2 -Category 1 and Category 2.

1)If Code starts with alphabets then

1.1)if it belongs to Product Group K01 ,it is categorized as Category 1

1.2) if it belongs to Product Group K05 ,it is categorized as Category 2

2)If Code starts with integer 6

2.1)if it belongs to Product Group K01 ,it is categorized as Category 1

3)If Code starts with integer 2

3.1)if it belongs to Product Group K05 ,it is categorized as Category 2

Input:

Product       Group Code
K01                YS4341
K05                YS4342
K01                YT0517
K05               YT0518
K01               642130
K05               642130
K01               690802
K05               690802
K01               290802
K05               290802


Output:

Product  Group Code     Category
K01           YS4341               Category1
K05           YS4342               Category2
K01           YT0517               Category1
K05           YT0518               Category2
K01           642130               Category1
K05           642130
K01           690802               Category1
K05           690802
K01           290802
K05           290802               Category2

 

Thanks,
Ruma

Labels (1)
1 Solution
4 Replies
seanbruton
Luminary Alumni
Luminary Alumni

Ruma,
I case of the rule looking at a alphabet is the alphabet always a “y” or can it be any alphabet from A to Z.

seanbruton
Luminary Alumni
Luminary Alumni

Ruma, 

Try this expression:

IF(Product = 'K01', 'Category1',
IF(Product = 'K05' and MATCH(LEFT(Group Code,1),'2','6'), 'Category2',
IF(Product = 'K05' and MATCH(LEFT(Group Code,1),'Y'), 'Category2',
NULL())))

 

Regards

ruma_barman
Creator
Creator
Author

Hi ,

It din't give expected output.