QGIS – Remove All Spaces in Attribute Fields Using Field Calculator

attribute-joinsfield-calculatorqgis

I've been trying to join two layers (one shapefile point-layer and one table without geometry) using one attribute column with mutual attributes. Normally this works perfectly.

However, only one fifth of the attributes are recognized and linked. This is really weird because I specifically checked that both the values are the same. I think the failed join might have something to do with the spaces in the field values (see screenshot).

Does anyone know a code to use in the field calculator to automatically remove all spaces in the attribute values? I want all values in the column 'DEFINITIEF' to be each one continuous string without spaces. I think the join/recognition of the same values will work better then. The type of column in the two layers is the same (Text, 100 characters).

screenshot column that I want to use to join the two layers

Best Answer

Use the replace QGIS function. So replace from the field "DEFINITIEF" the space characters (' ') with nothing (''): replace("DEFINITIEF", ' ','')

Related Question