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
1 Answer 1
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.
-
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.Muhammad Faizan Khan– Muhammad Faizan Khan2016年08月29日 08:16:43 +00:00Commented Aug 29, 2016 at 8:16
-
while i run your code[lpad("<integer BUILDINGID>",4,0)] it now given me null in dataMuhammad Faizan Khan– Muhammad Faizan Khan2016年08月29日 08:17:47 +00:00Commented Aug 29, 2016 at 8:17
-
if the field is named
id
, the formula should belpad( "id" ,4,0)
. You can select fields and functions in the right hand panel.AndreJ– AndreJ2016年08月29日 08:23:34 +00:00Commented Aug 29, 2016 at 8:23 -
it didn't worked lpad("BUILDINGID",4,0)Muhammad Faizan Khan– Muhammad Faizan Khan2016年08月29日 08:34:35 +00:00Commented Aug 29, 2016 at 8:34
-
and please tell me about my first commentMuhammad Faizan Khan– Muhammad Faizan Khan2016年08月29日 08:35:30 +00:00Commented Aug 29, 2016 at 8:35