1

I want to search for certain values in a column. If that value is found, I want to update another a cell in the same row, other column.

I tried

CASE WHEN "column1" = 9 THEN "column2" = 'SA' ELSE "column2" END

That did not work. How would I approach that?

1 Answer 1

3

Using QGIS 2.16, in the field calculator, set it up to update an existing field (the one you want the changes to take place). Then write a CASE WHEN statement like this:

CASE WHEN "column1" = 9 THEN 'SA' ELSE "column2" END

You don't need to reference the column you wish to change as the field calculator takes care of that.

EDIT:

For multiple values change the expression to:

CASE 
WHEN "column1" = 9 THEN 'SA' 
WHEN "column1" = 8 THEN 'TB'
WHEN "column1" = 7 THEN 'UC'
ELSE "column2"
END
1
  • for multiple cases I can use WHEN?
    – four-eyes
    Commented Nov 1, 2016 at 16:08

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.