Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Using padleft for varying digit quantities - 5 and 9 digit zipcodes missing leading zeros

kas
8 - Asteroid

Hello!

 

I have a column with zip codes that don't have the leading zeros. I can't use a simple Padleft ([ZIP],5, '0')  because some are only 3 digits 167  missing the leading zeros and some of them have the additional 4 digits, but missing the leading zeros  - for example 9072523 that should be 009072523

 

Suggestion for the best way to account for both situations?

 

Thank you!

Kim

5 REPLIES 5
MarqueeCrew
20 - Arcturus
20 - Arcturus

@kas ,

 

Please try this conditional formula:

 

 

IF Length([zip]) < 5	Then PadLeft([Zip], 5, "0")
ELSE PadLeft([Zip], 9, "0")
ENDIF

 

 

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

@kas - could you give us some sample zip codes and how they are currently structured in your data, and what the output needs to look like? It'll help the community get you exactly what you need.

kas
8 - Asteroid

Curent

9072523
731
730
9367113
9695331
9111238
9023557

921

 

Should be

009072523

00731

00730

009367113

009695331

009111238

00902357

00921

 

Thanks!

kas
8 - Asteroid

This works perfectly! 

Thanks so much!

AbhilashR
15 - Aurora
15 - Aurora

Thanks @kas. @MarqueeCrew's already posted a solution.

Labels