Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

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
16 - Nebula
16 - Nebula

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