Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
nareshthavidishetty
Creator III
Creator III

Categorize the data using sub field

Hi,

I have a field called 'Product ID' as below.

If the field values is end with 7539 we need to name it as ProductA and if field values is end with 17973 we need to name it as ProductB.

Capture.PNG

Thanks..

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

How about

LOAD ...

     [Product ID],

     Pick(Match(SubField([Product ID], '-', -1), '7529', '17973'), 'ProductA', 'ProductB') AS [Product Name],

     ...

FROM ...;

Your example contains only two cases. If you need to translate a large(r) number of Product IDs, then use a Mapping Table instead of Pick/Match.

Best,

Peter

View solution in original post

3 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

How about

LOAD ...

     [Product ID],

     Pick(Match(SubField([Product ID], '-', -1), '7529', '17973'), 'ProductA', 'ProductB') AS [Product Name],

     ...

FROM ...;

Your example contains only two cases. If you need to translate a large(r) number of Product IDs, then use a Mapping Table instead of Pick/Match.

Best,

Peter

chinnuchinni
Creator III
Creator III

try this in script:

if(right(Product_ID,4)='7539','prod_A',if(right(Product_ID,5)='17973 ','prod_B','Prod_C')) as Prod

ChennaiahNallani
Creator III
Creator III

try like below

subfield(Fieldname, '-', 1) as ProductB,

subfield(Fieldname, '-', 2) as ProductA ,