5

I used this command to organize my treenumbers:

lpad("baumnummer", 6, '0')

So tree number 1 will be shown as "00001". I did this because in my layout lists every tree will be put into the right order.

Now I found another solution but I want to remove all the zeros beforehand from my Attribute table. How can I achieve that?

enter image description here

1 Answer 1

5

Try this expression with the to_int() function:

to_int("baumnummer")
-- to_int('000001') -> 1

If you wish to maintain the string field type, you could expand the expression above with the to_string() function to:

to_string(to_int("baumnummer"))
-- to_string(to_int('000001')) -> '1'

Additionally one can achieve the desired output with the format_number() function:

format_number("baumnummer",0,'de')
-- format_number('000001',0,'de') -> '1'
0

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.