openrefinegrel

sum function in GREL in OpenRefine


In OpenRefine, I'm trying to increase the value of every number in a column by 1.

The GREL expression sum([value],1) gives me Error: sum expects an array of numbers.

I guess I don't know how to produce an array of numbers. When I use a different function on the same column, such as tan([value]), I get the result I want.


Solution

  • I think you misunderstood the use of sum(). If you just want to add 1 to each cell, just use value + 1.

    enter image description here

    Make sure, however, that your column contains numbers (in green) and not strings (in black). If in doubt, use toNumber(value) + 1 instead.

    The sum() function allows to add all the numbers contained in an array, for instance sum([1,2,3,4]) = 10, but you have no array if each cell of your column contains a unique number.