1

I want to update attribute table BID column using below line

($id +002)

but it is not adding 00 at beginning. instead adding 2,3,4,5,...... I am very beginner and this is my first try to append zero zero into features table column. I am somehow manage to write this

'0000' || ($id + 5)

it adding zeros but changing exceeding the id length limits

asked Aug 29, 2016 at 7:18

1 Answer 1

2

You have to decide whether you want to have an integer or text field. If you want to do any arithemetics on the field, take integer, if you want trailing zeros, take a text field.

As a workaround, you can use an integer field, and use the field calculator to add a new, virtual field of type text, with this formula:

lpad( "<integer column name>" ,4,0)

This will make the field auto-updateable.

answered Aug 29, 2016 at 7:54
8
  • thanks @AndreJ is this possible to maintain 4 digit length and append '01' to every number. if the number like this you have 1, covert it to 0101.if you have 10 then covert it to 0110. Commented Aug 29, 2016 at 8:16
  • while i run your code[lpad("<integer BUILDINGID>",4,0)] it now given me null in data Commented Aug 29, 2016 at 8:17
  • if the field is named id, the formula should be lpad( "id" ,4,0). You can select fields and functions in the right hand panel. Commented Aug 29, 2016 at 8:23
  • it didn't worked lpad("BUILDINGID",4,0) Commented Aug 29, 2016 at 8:34
  • and please tell me about my first comment Commented Aug 29, 2016 at 8:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.