Using QGIS field calculator to replace null values with values from another field

field-calculatorqgis

I have combined several shape files together in QGIS from some OSM data. I am trying to use the field calculator to set the null values of one attribute to have the values of another.

enter image description here

I am trying to make the null values of the landuse attribute equal the not null values of the Nature attribute

I think this is primarily an issue with my understanding with the QGIS field calculator syntax, I have tried using multiple conditional operators and cannot run the query due to this error

first attempt at writing the query

Parser Errors:
syntax error, unexpected NAME, expecting $end

Second attempt at writing query

definitely do not understand the syntax

Best Answer

It should be

case
    when "landuse" is null then "Nature"
    else "landuse"
end

Unless you actually have the string NULL in your field. Then replace "landuse" is null with "landuse"='NULL'

You can use select by attributes to find out.

Related Question