Alteryx Designer Desktop Discussions

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

Change a 2-3 digit number/string to a 5 digit number/string

kp88
5 - Atom

I have a workflow where I need to convert a 2 or 3 digit string (or number) to a 5 digit string (or number). Ex: change 102 to be 00102. In Excel, I would use the formula text(ref cell,"00000") but can't find anything similar in formulas or by trying to convert to a string. 

 

 

4 REPLIES 4
ddiesel
13 - Pulsar
13 - Pulsar

Try this formula:

PadLeft(tostring([Field1]),5,"0")

 

I found the answer in this post by @

How do I pad leading Zeros?

 

See attached.

kp88
5 - Atom

Hmm I'm still having issues. I already have the field type as a String. With the "" around the 0, I'm now getting the below error

The field "" is not contained in the record. (Expression #1)

 

formula is padleft([RecID],5,"0")

 

Any thoughts?

ddiesel
13 - Pulsar
13 - Pulsar

Try giving a name to your Output Column in your Formula tool.

 

Where it says "Select Column", drop down to choose a column to replace or click "+ Add Column" and type a description.

kp88
5 - Atom

Oh DUHHH! Thank you!

Labels