Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Cannot Trim blank spaces from a string

KB
7 - Meteor

Hi, I have a string which have some empty spaces before the text. Using trim function (trim, trimleft) does not work, when I copy the data to excel or notpad they seem to be just a blank spaces. Any idea how can I remove them and make the data consistent. Just  as a side note the records of this column have different lenght.

Thanks Record_trim.png

4 REPLIES 4
KB
7 - Meteor

Ok I have found the solution using the regex_replace function which I have picked up from MattD https://community.alteryx.com/t5/Alteryx-Knowledge-Base/Remove-Leading-Trailing-All-Whitespace/ta-p/....

 

I am still copnfused though  why trim funcion did not work as it seemed that all leading whitespaces are in front of the string.

 

Thanks

 

tom_montpool
12 - Quasar

I tested with a non-breaking space as the first character and the TRIM function doesn't remove it. This is probably what is happening in your case so the RegEx approach is more 'generous' in the definition of whitespace.

 

Note, though, that the Alteryx TRIM function is fully specified as TRIM(x,y) where x=your field to be trimmed and y=the character you want to trim so if you knew the ASCII code for the character that wasn't getting trimmed, you could specify it as the y argument.

MajorBhatti
6 - Meteoroid

Hi,

 

I had a same problem but find a solution.

 

Please use RegEx as tool as shown below. Select field from "Field to parse" and select Regular Expression as \s$ and keep

replacement text as blank. I am sure it will work if not share your screenshot with me.

Capture.JPG

AGilbert
11 - Bolide

Ran into this problem today and leaving a few resources here for others who may find this thread. 

 

The trim function can be used to remove a non-breaking space, albeit with the help of CharFromInt(). My solution is below and some troubleshooting/exploratory steps are attached. 

 

solution.PNG

 

Additionally, this Community thread  is a good resource for a regex solution.

https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Elegantly-remove-all-ASCII-cha... 

Labels