Alteryx Designer Desktop Discussions

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

Adding zero in front of the value

SH_94
11 - Bolide

Dear community,

 

I would like to ask how we going to add zero in front of value below so that the length of value for each row is five. My main goal is i want to make all the value under column A , the length all is five, by adding those zero in front. 

 

However, it is quite flexible which mean some value need to add two zero and some need to add three zero, how do we able to aumatically adding zero in front so that all value is 5 in length

 

SH_94_0-1658997040828.png

 

Many thanks for the support

 

 

3 REPLIES 3
IraWatt
17 - Castor
17 - Castor

Hey @SH_94,

Slightly inelegant but you can use a formula like this:

IF Length([Input]) = 5 THEN [Input] 
ELSEIF Length([Input]) = 4 THEN "0"+[Input] 
ELSEIF Length([Input]) = 3 THEN "00"+[Input] 
ELSEIF Length([Input]) = 2 THEN "000"+[Input] 
ELSEIF Length([Input]) = 1 THEN "0000"+[Input] 
ELSE "00000" ENDIF

IraWatt_0-1658997422480.png

The community has some quick and easy videos on formulas and the Formula Tool here https://community.alteryx.com/t5/Interactive-Lessons/tkb-p/interactive-lessons/label-name/Writing%20...

 

Any questions or issues please ask! 
Hope that Helps

Ira Watt
Technical Consultant
Watt@Bulien.com 

DataNath
17 - Castor

The PadLeft() function allows you to add x amount of your chosen character to the field, in order to bring it up to the length you want. In this case 5. There's also a PadRight() function that will do the same but add them to the end:

 

DataNath_0-1658997763932.png

Minerd0119
5 - Atom

Is there a way to keep the leading zeros when exporting data in a .csv format?

 

Thank you

Labels