community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx Designer Knowledge Base

Definitive answers from Designer experts.

How To: Remove Leading Zeros From a Field

Alteryx
Alteryx
Created on
How To: Remove Leading Zeros from a Field
 
You can use the Formula Tool and the TrimLeft() function to remove leading zeros.

 

TrimLeft(String,"y") - Removes y from the beginning of String. Defaults to trimming whitespace.

 

TrimLeft([Field1],"0") removes all 0 characters from the beginning of the string. If you do not want to replace 0 with "", filter all records that == '0', use TRIMLEFT() on all other strings, then union the results.

 

Note:  Using Trim() will remove the string from the beginning and end of the string.

 

Sample Input:

 

2019-02-28_17-19-29.png

 

 

 

 

 

 

 

 

 

 

 

 

 

Sample Output:

 

2019-02-28_17-21-02.png

 

 

Formula Configuration:

 

2019-02-28_17-22-30.png

 

 

You could also use the Regex tool to find and replace leading zeros. 

Attachments
Comments
Asteroid

This is super helpful. Thank you!

Meteor

Angelo

 

I'm a new comer to Alteryx and the community.  I notice your post for removal of leading zeroes was written back in 2016.  My question to you is would you the Select Function now to perform this?

 

Tim

Asteroid

Wouldn't that RegEx replace all of the zeros?  (Not only the leading zeros)

Meteor

Ms. Bindy

 

As I found out later, YES!!

 

Thanks for getting back!

 

Tim