if(value.contains(/(FIXED|Closed|Done|COMPLETED)/),"Closed","Open")
if(value.contains(/(FIXED|Closed|Done|COMPLETED)/),"Closed","Open")
Note that rather than creating a new column for the 'NewStatus' value, you can use a Custom Text facet with an expression like:
if(value.contains(/(FIXED|Closed|Done|COMPLETED)/),"Closed","Open")
This would give you the ability to easily filter Open vs Closed without creating an additional column.It doesn't really matter, but just highlighting this - I use Custom Text facets a lot for this type of task
Owen
On Tuesday, May 28, 2019 at 3:25:01 PM UTC+1, Owen Stephens wrote:
So there are a few ways of approaching this in OpenRefine :)If you want to do it in one GREL expression I'd use `contains` with a regular expression like:
if(value.contains(/(FIXED|Closed|Done|COMPLETED)/),"Closed","Open")Just add to the list of terms in the brackets separating each "Closed" value with the pipe | characterAn alternative approach using Facets is:* Create a Text Facet on the column* Select all the "Closed" statuses in the Facet* Do a GREL transform on the rows to put the value "Closed" in all these rows* Invert the selection to have all the "Open" status rows* Do a GREL transform on the rows to put the value "Open" in all these rowsWhile this is a little clunky the first time, once you've done this in one project, you can apply the same changes from the History to any other projects you have easily - so you only have to do it once.Hope all of that makes sense - let me know if you have any questions
Owen,
On Tuesday, May 28, 2019 at 3:14:44 PM UTC+1, MRB wrote:Hi Owen,I have a column named Status, with text values such as 'FIXED', 'Closed', 'Done', and 'COMPLETED' that I want to consolidate into a new status field NewStatus as 'Closed'.There are eleven other values such as 'Open', 'Awaiting Dev', 'Awaiting UAT', etc that I want to consolidate into the NewStatus field as 'Open'This would let me quickly separate out open vs closed tickets.Thanks,Mark
On Tuesday, May 28, 2019 at 9:40:13 AM UTC-4, MRB wrote:Greetings,I didn't see any mention but was wondering if they exist in GREL. I need to create a new column that consolidates 20+ status indicators into 2 values and was looking for a better way to it consolidate than using a very deep set of nested if statements.I don't know Python/Jython/Cloture - but if can be done that way, I would appreciate a sample of how to do it.Thanks,Mark
--
You received this message because you are subscribed to the Google Groups "OpenRefine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openrefine+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openrefine/702e1bae-9f37-4c62-928d-317e1e749518%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Just go into the Facet menu in a column and you should see the option to create a Custom Text Facet
Owen