2

How to split a "Field" into "Field 1" and "Field 2" when the comma is a separator in the field?

I am using Field Calculator in QGIS.

3

If you want to use the field calculator, it is quite straightforward. To get everything to the left of your comma use the following expression:

left("myField", strpos("myField", ','))

To get everything to the right of the comma use this expression:

right("myField", length("myField")-(strpos("myField", ',')+1))
  • In both cases, comma remains in a new substring. I assume it should include "-1", i.e. left("myField", strpos("myField", ',')-1) for "myField" values like 'My Street, 1A'. – Taras Feb 12 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.