7

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

5
  • 3
    What is the actual expression you tried ?
    – Kalak
    Sep 9, 2022 at 12:26
  • 1
    This could be done using the "if" function or a "CASE" expression. Edit your question with the expression you tried so we can check for error
    – J.R
    Sep 9, 2022 at 12:29
  • BTW SQL equivalent to "equal the not null" - is not null. "equal the null" - is null. Field names must be in double quotes "
    – RainForest
    Sep 9, 2022 at 12:30
  • edited the question to show some of the expressions i wrote
    – Mr_Chap
    Sep 9, 2022 at 12:35
  • This could help you to better use the expression string builder : docs.qgis.org/testing/en/docs/user_manual/expressions/…. If needed the left part of the expression string builder has an help (you may need to click on the "show Help" button) with syntax and usage example for all function (just select a fonction on the list to display)
    – J.R
    Sep 9, 2022 at 13:03

1 Answer 1

5

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.