Alteryx Designer Desktop Discussions

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

Using Excel Text() Formula

tarichar
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'. 

2 REPLIES 2
jamielaird
14 - Magnetar

Hi @tarichar 

 

Something like this should work:

 

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

 

tarichar
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