Help

Re: Add leading zeros to only certain values

Solved
Jump to Solution
3052 0
cancel
Showing results for 
Search instead for 
Did you mean: 
junaid2ali
5 - Automation Enthusiast
5 - Automation Enthusiast

I have a column named MIN and need to add leading zeros when the value in column is less than 4 numbers:

BeforeAfter Formula
220022
4560456
1000010000
8888888888
999999999999999999

This is what I have right now but is giving me an error for the largest number:

IF((COUNT(MIN) <= 3), (REPT('0',4 - LEN({MIN} &''))&{MIN}), {MIN}))

1 Solution

Accepted Solutions

Try adding a ` & ""` to your initial LEN(), the same way you're handling your second LEN()

IF((LEN(MIN & "") <= 3), (REPT('0',4 - LEN({MIN} & ''))&{MIN}), {MIN})

Screenshot 2023-03-30 at 11.01.00 AM.png

See Solution in Thread

3 Replies 3

Change the "COUNT" to a "LEN" and it should work fine:

IF((LEN(MIN) <= 3), (REPT('0',4 - LEN({MIN} &''))&{MIN}), {MIN})

That didn't work for me and am now getting an error message in the column cells, the value is a number, will LEN work with that?

Screen Shot 2023-03-29 at 10.01.21 AM.png

Try adding a ` & ""` to your initial LEN(), the same way you're handling your second LEN()

IF((LEN(MIN & "") <= 3), (REPT('0',4 - LEN({MIN} & ''))&{MIN}), {MIN})

Screenshot 2023-03-30 at 11.01.00 AM.png