Hello!
I got confused in the code for combining product categories in the rule engine node. Could you help me anybody?
I try to realise the follow scheme:
If product category = Apparel, then Union_category = Apparel
If product category = Office, then Union_category = Office
If product category = Drinkware, then Union_category =Drinkware
If product category = Lifestyle, then Union_category= Lifestyle
If product category = Bags, then Union_category= Bags
If product category = Headgearl, then Union_category = Apparel
If product category = Notebooks & Journals, then Union_category = Office
Of product category = Waze, then Union_category = Waze
If product category = Bottles, then Union_category =Drinkware
If product category = AcŃessories, then Union_category =AcŃessories
If product category = Fun, then Union_category =AcŃessories
If product category = Gift cards, then Union_category =Gift cards
If product category = Housewares, then Union_category= Lifestyle
If product category = Google, then Union_category =Drinkware
If product category = Backpacks, then Union_category= Bags
Product_category current, Đ° Union_category new
Hello @Vira_Maykova
The operator =
works for comparing numeric types. If comparing strings you can use the operator LIKE
Settings:
Append Column: Union_category
$product category$ LIKE "Apparel" => "Apparel"
...
BR
Hi,
The =
operator also works with string types, however, it will then test for exact matches. LIKE
allows the use of wildcards and therefore yields fuzzy matches. In terms of performance, it is recommended to go for exact matches rather than fuzzy matches but if your table is not too large (e.g. less than a few hundreds of thousands of lines), this little detail wonât matter.
Another point to consider with Rule Engine is that the order of the rules is important. Anything that matches a preceding rule is out of the selection for the next rule and canât be changed anymore. If your rules are formulated in such a manner that they are mutually exclusive, the order wonât matter.
Finally, if you want to generate an ELSE rule, the following rule formulation will work as a final statement in your sequence of rules:
TRUE => "Anything else"
Kind regards,
Geo
Thank you I done correct!
how do you think, why this scheme donât work with row âAccessoriesâ I have missing values after all.
Hello @Vira_Maykova
I cannot see the whole picture from captures, but there could be few reasons behind.
In example: your code runs for exact match for the quoted text. If there are leading or trailing white spaces or non-printable unicode⌠this expression won´t find an exact match; then we start to talk about wildcard matching⌠you can use LIKE "*Accessories*"
aiming to get the match.
However you will have to start caring about the rule order, if this word is included in other logical rules:
If you can share a sample of your data, we would take a look into it.
BR
Sure, you can see this data set on this link knime_correct1.csv - Google Drive.
Hello @Vira_Maykova
Iâve tested the data and I cannot reproduce the error (missed items). Original data summary:
The following expression works fine for me:
Replace Column: Union_category
//
$Product_Category$ LIKE "Accessories" => "Accessories"
TRUE => "Other"
BR
Thank you very much, Iâve tried diff ways to solve the problem, and in the end I replace missing values to avrg means.