Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Alteryx is here to help you solve your biggest data challenges. Read about the new Virtual Solution Center here.
SOLVED

Parsing a specific number of characters within a string

Highlighted
6 - Meteoroid

Dear community,

 

Please I am having some difficulties using Regex to extract a specific part of a string field within my Data.

I have for example a field with the following string: 99999998_20180501_001_21_11+22_ORDERS

 

I will like to extract the Year and Month (marked in green) for each single record within that field. The field ist automatically generated and the date changes depending on the date of input of the record (YYYYMMDD), else the format remains the same for all the records. Only exception could be the prefix that could vary between "ORDERS" and "OFFERS"

 

I will appreciate your assistance.

 

Thanks

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

Hello @Desa19,

 

I've put you two ways to get to the same info with some extra columns to classify by date.

 

Untitled.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Regards

Highlighted
Alteryx Partner

Hi @Desa19,

 

You could use the following expression to parse the YearMonth into a new column:

 

\d+_(\d{6}).*

 

image.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Regards,

Jonathan

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

This can be done in a single Formula tool. This will work for the 8-digit date string in any position in the input string, as long as it is bound between two underscores.

 

Left(REGEX_Replace([Input],".*\_(\d{8})\_.*","$1"),6)

 

Highlighted
6 - Meteoroid

@CharlieS @Jonathan-Sherman @afv2688,

 

please accept my appreciations for the timely assistance, I just successfully pulled the right results with all three options. 

 

@CharlieS @Jonathan-Sherman: your proposed solutions, though slightly different approaches nail the problem on the point with the exact solution.

@afv2688's Option broadens my scope further on how to correctly format the Regex Tool for other possible outputs.

 

Thanks for all 

Labels