Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
ALTER.NEXT:

Join us on Dec 2 for a half-day virtual analytics + data science event!
US & CA customers only

SAVE YOUR SPOT
It's the most wonderful time of the year - Santalytics 2020 is here! This year, Santa's workshop needs the help of the Alteryx Community to help get back on track, so head over to the Group Hub for all the info to get started!
SOLVED

Using Excel Text() Formula

Highlighted
6 - Meteoroid

How do I write a formula to convert a number to a text field with 4 characters? In Excel, I use a simple Text() formula: =text(A1,"0000") where A1 equals 123 and the output adds a leading '0' to '0123'. 

Highlighted
Alteryx Certified Partner

Hi @tarichar 

 

Something like this should work:

 

PadLeft(ToString([FieldName]),4,"0")

 

Highlighted
6 - Meteoroid

Thanks for the feedback; however, I also have values in my data sample that already have leading 0's that need to be removed as well: i.e. 001234 needs to convert to 1234. Would I need to write a separate PadRight formula or is there a different formula that would address both conditions? Thanks again, and apologies for not listing this scenario in my original inquiry. 

Labels