In case you missed the announcement: Alteryx One is here, and so is the Spring Release! Learn more about these new and exciting releases here!

Alteryx Designer Desktop Discussions

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

Concatenate until reaches specific length

cutehappybear
7 - Meteor

Hello,

 

I have a table, and there is 1 column with variable length. I want to do an if condition: if the length of the values in this column is less than 10, then I want to concatenate 0s to the left of it until it reaches length 10.

For example: 666666 -> 000066666; 12345 -> 0000012345

Can I do this using a formula tool? Any sugestion?

2 REPLIES 2
ShankerV
17 - Castor

Hi @cutehappybear 

 

Please use the function PADLEFT([columnname],10,"0")

 

 

Note: The column should be string datatype. To get this formula work.

 

 

OllieClarke
15 - Aurora
15 - Aurora

Hi @cutehappybear just to slightly amend @ShankerV's suggestion - as the PadLeft() is a string function, you'll need to ensure the field is a string field

PadLeft([String],10,"0")

Or can convert it in the calc

PadLeft(ToString([num]),10,"0")

Either way the leading Zeros will need to be wrapped in quotes

 

Hope that helps,

 

Ollie

 

Labels
Top Solution Authors