In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

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

Formula Split at Hyphen

mattcoleman
8 - Asteroid

Pretty simple request that I can't seem to get working.

 

I have data that varies in length, but there is a hyphen and I only want what's before the hyphen. I'm guessing I should be using a Formula tool?

 

EXAMPLE: Factory Cost Centers-Business Admin....all I want is Factory Cost Centers. The hyphen always defines the split.

 

Thanks in advance!!!

3 REPLIES 3
jrgo
14 - Magnetar

Hi @mattcoleman,

 

You can use the RegEx_Replace() function within the formula tool to do so. Here's the expression:

REGEX_REPLACE([Field],'^(.+?)-.*$','$1')

Without going too much into details, this regex is saying from the start of the string, capture all characters until it finds the first '-'.

 

Hope this helps!

 

Jimmy

mattcoleman
8 - Asteroid

Worked perfectly, thanks Jimmy!

KaneG
Alteryx Alumni (Retired)

Without REGEX you could try

 

Left([Field],Findstring([Field],'-'))

 

That will find the character number of the hyphen and take the left characters before it

Labels
Top Solution Authors