6

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.

Paul M
  • 3,937
  • 9
  • 45
  • 53

1 Answers1

7

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.

Thad Guidry
  • 579
  • 4
  • 8
  • 5
    Alternatively you could modify the GREL to include this step (leaving the original column as a string) - if(value.toNumber() > 5, "True", "False") – Owen Stephens Oct 14 '16 at 08:28
  • ahh, I just presumed as it was a number it was treated as numeric, but it was being treated as a string. Used edit cells to trim whitespace (no cells changed), then used the common transformation 'to number'. Data was imported from a csv out of a database where it was numeric. Now my numers are 'green' and the equation works. Thanks. – Paul M Oct 14 '16 at 11:16