Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
MarioMazzoli
Contributor
Contributor

Data categorization according to keywords

Hi,

I'm fairly new to Qlik, so forgive me if my question is pretty "easy".

I have two tables.

Data table:

Item textValue
Fee for XXX4
Manual adjustment for xxxxx2

 

Keywords\category:

KeywordCategory
FeeMemberships
Adjustment

Manual input

 

I would like to add a third column to the first table, containing the category of the item according to the table of Keywords\Category (searching for Keywords on the Item text column), like this:

Item textValueCategory
Fee for XXX4Membership
Manual adjustment for xxxxx2Manual input

 

I'm trying by adding a Calculated field in the first column, but I'm not able to find the right expression.

Can you help me?

Thanks in advance,

 

Mario

1 Reply
ChiragPradhan
Creator II
Creator II

Try this - 

DataTable:
LOAD * Inline [
ItemText, Value
Fee for XXx, 4
Manual Adjustment for xxxxx, 2
];

KeywordCategory:
LOAD * Inline [
Keyword, Category
Fee, Memeberships
Adjustment, Manual Input
];

NoConcatenate
KeywordMap:
LOAD Replace(chr(39)& Concat(DISTINCT '*' & Keyword & '*',',') & chr(39), ',' , Chr(39) & ',' & chr(39)) As Keyword,
chr(39)&Concat(Category,chr(39)&','&chr(39) )&chr(39) as Category
Resident KeywordCategory
Order by Keyword ASC
;

Let vKeywords = peek('Keyword',0);
Let vCategory = peek('Category',0);


NoConcatenate
Final:
Load
ItemText
,Value
,pick(wildmatch(ItemText, $(vKeywords)),$(vCategory)) AS Category

Resident DataTable;

DROP Tables KeywordCategory, KeywordMap, DataTable;