6

I have two columns of the same data and I want to unite

for example I have the column "pole_type" and "pole_type_" and sometimes one has values and some times the other

like seen in the photo

enter image description here

I want to get all the values in "pole_type_" into "pole_type" so I can delete the first

Iv'e used so far the following rules but not succeeded

IF(NULL,"pole_type_","pole_type")

or

IF("pole_type='',"pole_type_","pole_type")

and so on but I havn't came up with anything that works.

3
  • 1
    Assuming empty are blank, not NULL (your second example), try adding a second = and remove the space : IF("pole_type"=="","pole_type_","pole_type")
    – SMiller
    Commented Oct 24, 2018 at 16:27
  • Are you able to perform a selection of your data (outside of the calculator) for either blank or NULL? An example of selecting for NULL is here: gis.stackexchange.com/questions/16134
    – SMiller
    Commented Oct 24, 2018 at 16:30
  • 2
    In the screenshots your column is called "/_pole_type" (with an underscore at the start) but your formulas use "pole_type_" (with an underscore at the end).
    – csk
    Commented Oct 24, 2018 at 16:50

3 Answers 3

15

Welcome to the wonders of COALESCE. Try this:

COALESCE( "pole_type_" , "pole_type" )

It will return the first non-null value in a list. If they are all null, it will return null.

0
6

You can use:

CASE WHEN "pole_type" IS NULL THEN "pole_type_" ELSE "pole_type" END

1

Another way, less efective, but easy for new users like me, could be:

Select by expression "pole_type" is NULL

enter image description here

Then make your table editable and update field "pole_type" with "pole_type_", but only selected features.

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.