We have extended our Early Bird Tickets for Inspire 2023! Discounted pricing goes until February 24th. Save your spot!

Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer and Intelligence Suite.
SOLVED

Adding Zeros in Front of a Number to Reach Certain Number of Digits

atamertarslan
8 - Asteroid

Dear all,

 

I have a very basic question.

 

Imagine I have a list consisting of many entries with integer values of different number of digits, sometimes 5 sometimes 7. In the end I want to have a string with 10 digits/chars. That means if an entry has 5 digit number then 5 times zero should be added in front of that integer, if it has 7 digit number then 3 times zero.

 

Obviously, I can do this with a giant if else loop but I would very much appreciate an elegant way that will save me some time!

 

Best,

Atamert

2 REPLIES 2
PhilipMannering
15 - Aurora
15 - Aurora

You can use the Formula Tool,

 

 

padleft([Field1], 10, '0')

 

 

You would need to make sure [Field1] is a string by either using the Select Tool or ToString([Field1]).

kyle
5 - Atom

Any way we can use this for a double data type? Says for string only.

Labels