Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

ADDING ZEROS TO A COLUMN

dunkindonut7777
8 - Asteroid

Hi, I just got a problem solving with these account codes.

How to add 0s in start of each digits. The account code should have 10 digits but some of it has only 9 or 8 and even 2 digits only. I just want to make it in 10 digits the same other values under the account code column.

 

E.g

 

Account Code:

 

6100110001
6100110010
6100110010
6100110011
6100110015
6100110016
10020509
10010232
50101301
3512723503
3512843503
3512773503

 

The other values have 10 digits but the others have not, so I want to make it into 10 with adding zeros at the start, or at the left.

 

Can you help me with this please? Thank you!

4 REPLIES 4
MarqueeCrew
20 - Arcturus
20 - Arcturus

@dunkindonut7777 ,

 

 you're looking for the padleft function:

 

padleft([account code],10,"0")

 

 given that account code is a string. 

cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
AbhilashR
15 - Aurora
15 - Aurora

Hi @dunkindonut7777, Alteryx has an inbuilt function to help address these scenarios (PadLeft). You could introduce a formula tool and structure your formula to look something like:

PadLeft(
        tostring([Field1])
	, 10
	,'0')

tostring([Field1]) ensure the field coming into the Formula tool is converted into a string datatype, after which the PadLeft does it magic.

AbhilashR_0-1606362188823.png

 

I hope this helps.

grazitti_sapna
17 - Castor

hi @dunkindonut7777,

 

 

you have to do padding on the left side with 0's as per your scenario. Here is the sample workflow for the same.

 

grazitti_sapna_0-1606390161107.png

 

 

I hope it helps.

 

Sapna Gupta
dunkindonut7777
8 - Asteroid

Thank you for this!

 

Labels