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.

Hayden Elza
  • 559
  • 4
  • 12
tristramit
  • 507
  • 2
  • 12
  • 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 Oct 24 '18 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: https://gis.stackexchange.com/questions/16134 – SMiller Oct 24 '18 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 Oct 24 '18 at 16:50

3 Answers3

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.

Hayden Elza
  • 559
  • 4
  • 12
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

Pescariz
  • 882
  • 1
  • 8
  • 17