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.


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 '19 at 8:10

My solution: array_to_string(array_slice(string_to_array( "string.Split.By.Dot",'.'),1,3),'.') => "string.by.dot" Where 1,3 is index of the start and end of slice.

Your Answer

