Code for blank cells with IF function

587 views
Skip to first unread message

Lukas Bechera

unread,
Aug 30, 2017, 4:11:58 AM8/30/17
to OpenRefine
Hi guys,

I need to fill blank cells with data from other sells. I have 2 columns "item - g:price" and "item - g:sale_price". In g:price column is original price and when there is a discount in the "g:sale_price" is the price after the discount and if there is no discount there is no value in this column.

So I need a function like IF "item - g:sale_price" is blank, then write in the cell the price from column "item - g:price", otherwise keep the sale value in the cell.
I was trying to google it but no luck. Can you please write me here the code?

Thank you
Luaks

Thad Guidry

unread,
Aug 30, 2017, 6:48:30 AM8/30/17
to OpenRefine
Use a text facet on the "item - g:sale_price" column.
On the facet, click on "blank" to facet only blank values (which are null or empty cells)
On the "item - g:sale_price" column use Edit cells -> Transform with the GREL expression:

cells["item - g:price"].value


--
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+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ettor...@gmail.com

unread,
Aug 31, 2017, 6:02:03 AM8/31/17
to OpenRefine
Hi Lukas,

If you really, really want to perform the operation with a GREL formula, you can use this one:

if(isBlank(value.trim()), cells['item - g:price'].value, value)

The if and isBlank functions are documented here.
Reply all
Reply to author
Forward
0 new messages