Concatenate columns seperated with comma and space only if following field is not empty

Dear all,

friday I came across a small problem.

My source file has 4 columns containing address information.
I would like to concatenate them separated by comma and have done so in the expression editor for modify columns action.

Unfortunately this sometimes might result in poor looking results because sometimes some adresses are shorter.

OK: Street, Building, Postcode and place, Country

Not OK: Street, , ,

Means: Sometime there are addresses which do not have all information; if I just concatenate like [column1]&", "&[column2] then sometimes I will get resulting entries like above: Empty fields followed by comma space.

Is there any possibility to insert the comma space only is the field is not empty?

Best regards,

Hi Patrick,

If you can be sure that the first column always has a value, you can use the following expression:

[column1] &
when(not isempty([column2]), ", " & [column2]) &
when(not isempty([column3]), ", " & [column3]) &
when(not isempty([column4]), ", " & [column4])`

1 Like