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

Converting different string lengths and types into 5 characters

whitkrieng
8 - Asteroid

Hi all,

So I have a field that has disparate length sizes and types.  

 

output can look like: 

 

Field 1

313

3

00016-F

122

00011-L

 

 

I would like to convert the field to a 5 character string and also stripping off the last letter.  So the output would look like this:  

 

00313

00003

00016

00122

00011

 

I feel like this would need to be some sort of IIF and Length statement.  Thanks for your guys' help.   

3 REPLIES 3
patrick_digan
17 - Castor
17 - Castor
Try left (padleft([field1],5,"0"),5)
MSalvage
11 - Bolide

@wkrieng1, 

 

Use a Regex tool with:

 

Regular expression: (\-\l)

Output method: Replace

Case insensitive: on

nothing in replacement text

 

This will remove the -letter at the end of some of them. Then you just need to use PadLeft([Field], 5, '0') in a formula tool. Example attached.

 

Good Luck, 

MSalvage

 

whitkrieng
8 - Asteroid

Thank you, that was much more straightforward than I thought! 

Labels