0

enter image description here

What is the right expression for the QGIS Field calculator to get value string-field like "new field"?

Vince
  • 20,017
  • 15
  • 45
  • 64
mayoz
  • 1

1 Answers1

1

You can create a new string field front field within the Field calculator, populating it with the following expression

 substr("field",1,4)

This way, you extract 4 characters, starting from the first one, of the field field. Similarly, you can create and populate middle field and back field with these other expressions

 substr("field",5,5)
 substr("field",10,4)

Please note that your example has 5 digits in the first row of the middle field but only four in the other two. If that was intentional, you should use a conditional statement similar to

case when "field" = '0104030002101' then substr("field",5,5)
else substr("field",5,4) end
jpinilla
  • 3,230
  • 1
  • 12
  • 24