Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
ruma_barman
Contributor

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

Accepted Solutions
ruma_barman
Contributor

Re: Multiple if statement with "or" and "and"

4 Replies
Luminary
Luminary

Re: Multiple if statement with "or" and "and"

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.

Luminary
Luminary

Re: Multiple if statement with "or" and "and"

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
Contributor

Re: Multiple if statement with "or" and "and"

Hi ,

It din't give expected output.

ruma_barman
Contributor

Re: Multiple if statement with "or" and "and"