Skip to main content

Enforce leading zeros

  • June 12, 2018
  • 3 replies
  • 287 views

Forum|alt.badge.img+4

I have a pre-existing order number in the format of “LS003456” that I would like to auto-generate. I’m using a second field with autonumber and then a formula like this:

CONCATENATE(“LS00”, AutoID)

which gives a result of:

LS00185
LS00186
LS00187

Is it possible to modify the formula so that there are always 6 digits after the “LS” and any leading zeros are maintained?

My end goal is to have a sequence like:

LS000001
LS000002
LS000003

LS999999

3 replies

Forum|alt.badge.img+5
  • Inspiring
  • 1386 replies
  • June 12, 2018

Use this formula:

'LS'&
REPT(
    '0',
    6-LEN(
        AutoID&''
        )
    )&
AutoID

  • New Participant
  • 2 replies
  • September 5, 2020

Use this formula:

'LS'&
REPT(
    '0',
    6-LEN(
        AutoID&''
        )
    )&
AutoID

Tnx! This solved my problem as well. :slightly_smiling_face:


Forum|alt.badge.img+8
  • Participating Frequently
  • 14 replies
  • November 12, 2022

Use this formula:

'LS'&
REPT(
    '0',
    6-LEN(
        AutoID&''
        )
    )&
AutoID

I just found this answer that also works so well and I find it more elegant

RIGHT(“000”&{Revision Level},3)