Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Is there a formula other then PADLEFT that just puts the 0 to the front of a string?

wonka1234
10 - Fireball

Padleft requires one to define how many characters to go left , how can I always just put a 0 to the front of a string no matter the length?

14 REPLIES 14
Luke_C
17 - Castor
17 - Castor

'0' + [String] should do it, unless I'm oversimplifying

wonka1234
10 - Fireball

@Luke_C  works, but what if it is an integer?

binuacs
21 - Polaris

@wonka1234 can you try '0'+toString([Amount]) and change your data type to V_String

wonka1234
10 - Fireball

@binuacs 

 

cant seem to get it working - see attached workflow.

TheCoffeeDude
11 - Bolide

TheCoffeeDude_0-1680824684046.png

Formula tool - "0" + ToString([yournumber])

wonka1234
10 - Fireball

@TheCoffeeDude doesnt work!

TheCoffeeDude
11 - Bolide

It works for me and that's how I was able to produce the screenshot. So let's ask this question, what does your formula look like?

TheCoffeeDude
11 - Bolide

Better yet... I downloaded your workflow. Ran it. It threw an error, so I entered debug to see what's going on. Your output column is still remaining as "F4" which is of Int32 data type.

 

TheCoffeeDude_0-1680838404178.png

 

danilang
19 - Altair
19 - Altair

Hi @wonka1234 

 

Alteryx(and most other programing languages) automatically strip leading 0s from numeric fields. To display leading 0s, you need to convert the field to a string type.  Make sure you do this just before you output the data, since you can't do math on string fields without the liberal use to ToNumber() functions.

 

Dan

Labels
Top Solution Authors