Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
The Expert Exam is now live online! Read about the specifics and what it took to bring it to life in the blog by our very own Elizabeth Bonnell!
SOLVED

How to remove certain characters from end of string IF

Highlighted
7 - Meteor

How do I remove certain characters from a string if and only if they are that character? For example:

 

I have a column with NAICs 3 Digit Titles that have a "T" inserted at the end of some cells but not all. How do I remove the "T" from ONLY the end of the string IF and ONLY if it is a "T"? To clarify, If there is not a "T" at the end of the string I want the string to remain the same. Also, I do not want to replace every "T" just the ones at the end of the string. 

 

NAICs 3 Digit Title
Professional, Scientific, and Technical ServicesT
Social AssistanceT
Sporting Goods, Hobby, Musical Instrument, and Book Stores
Real EstateT
Food Services and Drinking PlacesT
Specialty Trade ContractorsT
Merchant Wholesalers, Nondurable Goods
Furniture and Home Furnishings Stores
Real EstateT

 

 

Highlighted
10 - Fireball

If Right([Field1],1) = "T" then
Substring([Field1],0,Length([Field1])-1)
else
[Field1]
Endif

Highlighted
7 - Meteor

Thanks for the reply. Both of the following expressions worked except for all entries with "Professional, Scientific, and Technical ServicesT ", for cells with this string it left the T at the end::

 

If Right([NAICs 3 Digit Title],1) = "T" then
Substring([NAICs 3 Digit Title],0,Length([NAICs 3 Digit Title])-1)
else
[NAICs 3 Digit Title]
Endif

 

 

TrimRight([NAICs 3 Digit Title],'T')

 

 

I am not sure why it removed the "T" from all the other values except for this particular entry. Any idea what I am doing wrong?

 

 

Highlighted
10 - Fireball

Here is how the Formula tool should be setup with "NAICs 3 Digit Title" being the field you modify.  And you see with the Data Preview your value "Professional, Scientific, and Technical ServicesT" is changed to "Professional, Scientific, and Technical Services"


Formula.jpg

 

 Here is how Formula tool should be placed in your workflow.

 

Workflow.jpg

Highlighted
6 - Meteoroid

Thank you! It works well!

Labels