Alteryx Designer Desktop Discussions

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

TrimLeft function trims off one extra character

wenjuanchen
8 - Asteroid

Hi there,

 

I am using Trimleft function to trim a string. However, it trims off one extra character.

 

To be specific, I have a field with value "BBC Kmlfsgees - LI6 - KE GAIN/LOSS", and I want to trim off "BBC Kmlfsgees - LI6 - " and keep "KE GAIN/LOSS". So I use 

 

      TrimLeft([Field1], "BBC Kmlfsgees - LI6 - ")

 

But the result turns to be "E GAIN/LOSS".

 

Does anybody know why? In addition, how to fix it? I know that Regex_Replace can do the job. However, can we fix the issue with TrimLeft?

 

Thank you so much!

5 REPLIES 5
jrgo
14 - Magnetar

@wenjuanchen

 

The trim functions will trim off any set of characters that you’ve specified in the second parameter, not a specific string. It’ll continue trimming until it hits a character that wasn’t specified, which in this case the “E”.

 

try to use the ReplaceString() function instead.

jdunkerley79
ACE Emeritus
ACE Emeritus

I would consider the substring function as well

Substring([Field1], 21)

(I think 21 is the character length of you string to remove)

wenjuanchen
8 - Asteroid

Oops! I thought I could accept two solutions! I accepted yours first then the post after yours. But then yours is not accepted as solution anymore. Sorry! I tried Replace and it works well. Thank you so much!

wenjuanchen
8 - Asteroid

Thank you so much! I tried Substring and it works well! Though it should be 22 (there is a white space in front of KE...). Thank you so much for providing new ideas!

meighu
5 - Atom

Actually I think that specifies the characters to keep.  

Labels