Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Removing the first character of the column

fangyi189
8 - Asteroid

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

12 REPLIES 12
michael_d
8 - Asteroid

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

Kenda
16 - Nebula
16 - Nebula

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.

fangyi189
8 - Asteroid

Thank you for the solution!

PauloHS
5 - Atom
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!
ItsDan
6 - Meteoroid

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!

Kenda
16 - Nebula
16 - Nebula

Hi @ItsDan 

 

For your use case, I would recommend this expression:

replace(tostring([FieldName]),"-","")

 

 

ZoeM
8 - Asteroid

You have no idea how many times I played around with her formula to try and figure this out!!!!

 

You are awesome PauloHS!

munchkin100
7 - Meteor

Brilliant, it actually saved my life! Thank you @Kenda !

SWickerson
5 - Atom

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.

Labels