In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

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

Using Substring to Remove Last Digit on a 12 Character Field

Fescobar
8 - Asteroid

Hello Everyone,

 

First post!

 

I am using the formula stated below to try and remove the last digit on a 12 character field.  I am also doing the same thing when the UPC is 13 characters long. 

 

I am trying to use this formula posted by Joe S from Alteryx.

Substring([Field1],0,length([Field1])-1)

Substring Error 2.png

When I do execute it I get this error as well.

Substring Field Error.png

 

Any assistance will be greatly appreciated. 

 
8 REPLIES 8
marcusblackhill
12 - Quasar
12 - Quasar

Hey @Fescobar !

 

I think is because your are replacing the word "length" by the string length but is to you keep the word because is the formula name.

 

hope that helps.

marcusblackhill
12 - Quasar
12 - Quasar
Try this:
Substring([Corp Item UPC],0,length([Corp Item UPC])-1)
atcodedog05
22 - Nova
22 - Nova

Hi @Fescobar 

 

I agree with @marcusblackhill 

 

You formula might go like

 

Substring([Corp Item UPC],0,12)

 

You can provide sample data and expected output. We can help you out 🙂

 

 

Fescobar
8 - Asteroid

Thank you! 

 

This is an extremely small data sample.  

 

The Corp Item UPC Column (A) that needs either the 12th or 13th character removed.  The LEN Column (B) is a sanity check for me to get the correct numbers.

 

I also tried the formula below and I am seeing a different error.

Substring Error 3.png

 

Thank you!!

 

Fausto

atcodedog05
22 - Nova
22 - Nova

Ok

 

Adding to @marcusblackhill formula

 

Substring([Corp Item UPC],0,length(tostring([Corp Item UPC]))-1)

 

Currently [Corp Item UPC] is a number you can use Tostring () to convert it to string and use length which is a length function.

 

Hope this helps 🙂

Fescobar
8 - Asteroid

Thank you both!

 

 

It doesn't seem to like that either unless I am doing something incorrectly which is likely

 

marcusblackhill
12 - Quasar
12 - Quasar

Hey @Fescobar !

 

Now you have a data type problem, your trying to do a string function in a numeric field.replace the first [Corp Item UPC] by tostring([Corp Item UPC]), the rest you can keep the same.

marcusblackhill
12 - Quasar
12 - Quasar

Substring(tostring([Corp Item UPC]),0,length(tostring([Corp Item UPC]))-1)

Labels
Top Solution Authors