openrefinegrel

Simple OpenRefine IF to create a new column


Im trying to create a new column which contains true or false. Basically column A has a number in it, between 1 and 6, if its higher than 3 I want the new column 'match' to contain true, otherwise it contains false. Using the add column based on column in trying the following GREL

if(value > 5, "True", "False")

That basically results in EVERYTHING being false.

I know my IF statement is correct because the following works

if(value.length() > 1, "Double", "Single")

Im just confused why if Value is greater than 5 doesnt work, its obviously missing something but I cant seem to pinpoint it in the docs.


Solution

  • Your GREL if() is correct. Our docs for that are here: https://github.com/OpenRefine/OpenRefine/wiki/GREL-Controls

    But I wonder if you really have all number values in that Column ? Are all the values "green" color ? If not, try using Edit Column to Trim Whitespace and then convert the Text to Numbers. Then try your if() on that column again and see what happens.