Reputation: 761
I have a dataset like this, and I'm looking for a way to add a category, based on what kind of product I have.
Can I search for Apple
+ Orange
and assign them to a category named Fruits
, and similar with Milk
+ Wine
and assign them to another category, named Drinks
?
| Item | Category |
|-------|----------|
| Apple | | <-- Fruits
| Orange| | <-- Fruits
| Milk | | <-- Drinks
| Wine | | <-- Drinks
Or maybe a simpler method: find any rows containing Milk
and assign them to category Drinks
?
Upvotes: 0
Views: 158
Reputation: 486
magdmartin and Owen Stephens give good answers. Another simple way using GREL:
Edit column > Add column based on this column...
value.replace("Apple","Fruit").replace("Orange","Fruit").replace("Milk","Drink").replace("Wine","Drink")
You could keep adding .replace("whatever food","whatever category")
ad nauseum
Upvotes: 0
Reputation: 1560
As magdmartin says you can do this using facets and edits - the solution he describes is probably the simplest approach and least error prone. However, if you prefer to do in a single step you can use GREL to test the content of the Item cell and then set the value in the Category cell dependent on the content of the Item cell.
with(cells["Item"].value.toLowercase(),w,if(or(w=="orange",w=="apple"),"Fruits",if(or(w=="milk",w=="wine"),"Drinks","")))
This is the same approach as given by Ettore Rizza above but in GREL rather than Jython.
Upvotes: 1
Reputation: 1787
This is something you can do without code.
Item
field for each value Category
field edit
button next to the blank value in the Category
facet and type with the category you want to add. Item
facet or filter to move to the next category and repeat this process until you have categorized all yours items.Upvotes: 1