This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Hi all, I am quite new to Alteryx. I am trying to remove the first character of one column, it is currently a string now.
So ex.
111a
112b
113c
I want to make it so that it'll be
RowID
11a
12b
13c
Solved! Go to Solution.
Hi fangyi189,
You can use a formula tool with the built-in string functions in Alteryx to do this. There are a few ways you can achieve this, one way would be to use the formula,
Right([RowID],Length([RowID]) - 1), the minus one will strp off one character from the left of the string, I've attached an example workflow below.
Thanks,
Michael
Hey @fangyi189! RegEx could also be super helpful here. This expression could be added to a Formula tool and get you what you're looking for:
REGEX_Replace([Field1], ".(.*)", "$1")
Basically, this says keep everything after the first character in Field1.
Thank you for the solution!
I am not very good with regex, but just to help out someone who may have the same problem than me.
the number of dots before "(.*)" are the number of characters that you may need
example (one char):
REGEX_Replace([Field1], ".(.*)", "$1")
example (two chars):
REGEX_Replace([Field1], "..(.*)", "$1")
example (three chars):
REGEX_Replace([Field1], "...(.*)", "$1")
btw
Thank you Barnesk!
Hi BarnesK
I've tried this but it says it's not for a numeric field. Is there a similar formula to remove a minus sign from the beginning of a numeric field?
thanks!
Hi @ItsDan
For your use case, I would recommend this expression:
replace(tostring([FieldName]),"-","")
You have no idea how many times I played around with her formula to try and figure this out!!!!
You are awesome PauloHS!
Brilliant, it actually saved my life! Thank you @Kenda !
Hi. Can you help with the following; I'm receiving error (The field "" is missing. Compare the tool configuration with the input stream. Expression #1).
IF left([Clarity - Name],2) = "zz" THEN REGEX_Replace([Clarity - Name], "..(.*)", "$1") ELSE [Clarity - Name] ENDIF
Thank you.