Adding Leading Zeros

5 posts / 0 new
Last post
Breanna_28
Offline
Joined: 10/24/2016 - 15:02
Adding Leading Zeros

Good afternoon,
I am trying to add leading zeros to a character field and want all values in the field to have a character length of 9.  For example, I would like 1234B11 to be 001234B11.  Is there any easy way to do this within the Equation Editor window?
 
Thanks!

klmi
Offline
Joined: 02/13/2019 - 08:41

@compif(@len(Field)==7;"00"+Field;@len(Field)==8;"0"+Field; [...]) 

klmi
Offline
Joined: 02/13/2019 - 08:41

If you have IDEA 10.3 and above also Python could help you:

1) Make a new script fill.py and save it in the library as user defined function.

def fill(param):
    return param.zfill(9)

2) append a new char field with the following equation:

@python("fill"; FIELD)

Gugge
Offline
Joined: 05/02/2018 - 10:56

Hi Breanna,
@Right( @Repeat( "0" ; 9 ) + @Alltrim(FIELD) ; 9 )
will also solve Your problem.

Breanna_28
Offline
Joined: 10/24/2016 - 15:02

Awesome! That worked for me.  Thank you both for your help!