Condition statement with values

1,699 views
Skip to first unread message

Dawayne eason

unread,
Jan 25, 2021, 8:21:44 PM1/25/21
to OpenRefine
I have a task in Open Refine to  Create a new column high_priced with the values 0 or 1 based on the “price” column with the following conditions: if the price is greater than 90, high_priced should be set as 1, else 0.

So I'm trying to create condition statement which values greater than 90 is 1, else it will be 0.

Owen Stephens

unread,
Jan 26, 2021, 5:39:32 AM1/26/21
to OpenRefine
From the "price" column, use the "Edit column" -> "Add column based on this column" option. If the value in the "price" column is already stored as a number, you can use GREL:

if(value>90,1,0)

otherwise you will need to convert the "price" value to a number in the GREL:

if(value.toNumber()>90,1,0)

You are using 1 and 0 here, but because OpenRefine supports boolean values I might suggest using true/false instead
if(value>90,true,false)

Best wishes

Owen

Dawayne Eason

unread,
Jan 26, 2021, 8:49:09 AM1/26/21
to openr...@googlegroups.com
You are correct and I appreciate it.


--
You received this message because you are subscribed to a topic in the Google Groups "OpenRefine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openrefine/13F66Ef7FEQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openrefine+...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/openrefine/f68c8b22-4639-43ef-a98b-33343d0bcb18n%40googlegroups.com
.
Reply all
Reply to author
Forward
0 new messages