Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm fairly new to Qlik, so forgive me if my question is pretty "easy".
I have two tables.
Data table:
Item text | Value |
Fee for XXX | 4 |
Manual adjustment for xxxxx | 2 |
Keywords\category:
Keyword | Category |
Fee | Memberships |
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 text | Value | Category |
Fee for XXX | 4 | Membership |
Manual adjustment for xxxxx | 2 | Manual 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
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;