ADDING ZEROS TO A COLUMN
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi, I just got a problem solving with these account codes.
How to add 0s in start of each digits. The account code should have 10 digits but some of it has only 9 or 8 and even 2 digits only. I just want to make it in 10 digits the same other values under the account code column.
E.g
Account Code:
6100110001 |
6100110010 |
6100110010 |
6100110011 |
6100110015 |
6100110016 |
10020509 |
10010232 |
50101301 |
3512723503 |
3512843503 |
3512773503 |
The other values have 10 digits but the others have not, so I want to make it into 10 with adding zeros at the start, or at the left.
Can you help me with this please? Thank you!
Solved! Go to Solution.
- Labels:
- Google Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
you're looking for the padleft function:
padleft([account code],10,"0")
given that account code is a string.
cheers,
mark
Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @dunkindonut7777, Alteryx has an inbuilt function to help address these scenarios (PadLeft). You could introduce a formula tool and structure your formula to look something like:
PadLeft(
tostring([Field1])
, 10
,'0')
tostring([Field1]) ensure the field coming into the Formula tool is converted into a string datatype, after which the PadLeft does it magic.
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
hi @dunkindonut7777,
you have to do padding on the left side with 0's as per your scenario. Here is the sample workflow for the same.
I hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you for this!
