4

I have an attributetable with several columns. I want to change the values of column1 if they are NULL with the values of the same row in column5.

case WHEN column1 is NULL THEN 
END

How do I say "use the value from the same row"?

11

The field calculator always calculates on a row-by-row basis. So you can use:

CASE WHEN "column_1" IS NULL THEN "column_5"
ELSE "column_1"
END
  • 1
    Or coalesce("column_1", "column_5") – thibautg Jun 1 '16 at 20:54
  • @thibautg - That's even nicer! You should consider posting that as an answer :) – Joseph Jun 2 '16 at 9:00
6

You can also use coalesce to replace NULL values from column_1 by column_5.

coalesce("column_1", "column_5")
2

Open the attribute table and make it editable.

  1. Select by expression "column_1" isnull

  2. Along the top of the attribute table you an select in a drop down a column of your choice. Select "column_1"

  3. In the text box available write "column_5"

  4. Click "Update Selected"

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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