I have a field with number values (111,112,113,211,212,....) and want to extract only the first digit (111 -> 1, 259 -> 2 etc.).

I remember that there was some easy way to do that in field calculator, but not which it was.

Can anyone help?

I don't want to use CASE WHEN, since I have roughly 100 various numbers.

3 Answers 3


left("your field name here",1) will do the trick.

left() returns a string of a provided length from a field, counted from the left/beginning of the field.


Mathematically will be: "Field" // 10 ^ floor(log10("Field")) replace Field with the name of your field.


You can also use function regexp_substr:

Returns the portion of a string which matches a supplied regular expression.

 regexp_substr( "area", '(\\d{1})')

Which means, extract the first single digit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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