1

I am trying to get the field calculator within QGIS 3.20 to create a new field ("*NewField*") that matches text in another field ("name1") when a condition (= 1) is met in another field ("LabelNUM").

So far, I have tried:

IF("LabelNUM" = 1, "name1", NULL)

IF("LabelNUM" IS '1', "name1", NULL)

IF("LabelNUM" = 1, "*NewField*" = "name1", NULL)

But none of these have worked.

Here is my attribute table:

Attribute Table

For example, from this image I want a new field to display 'Ashlett Creek' for the row with the ID: 441566, and NULL for all the others.

1
  • When asking a question, instead of "none of these have worked" state what the result was and how it differs from what you want to achieve. Showing us also you field calculator dialog window would also help to identify your problem.
    – Babel
    Commented Jul 11, 2021 at 14:21

1 Answer 1

1

The first two of your three expressions is correct and should produce the correct result: a copy of the text in field "name1" in case field "LabelNum" has value 1 and empty (NULL) otherwise. Be sure to set Output field type to Text (string) and set a Output field length long enough for yours strings - see screenshot:

enter image description here

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.