# Alteryx Designer Discussions

The Expert Exam is now live online! Read about the specifics and what it took to bring it to life in the blog by our very own Elizabeth Bonnell!
SOLVED

## Extract partial text from a field based on multiple conditions

Highlighted
7 - Meteor

Hi Team,

I want the output to be as below in sample data.

1.If account number starts with 00 and the amount and text matches with another line item for which account number starts with 38, then I want the output to be the second number (ENTYrd000008ABC). Here I want the logic to remove space and / between EN and TY.

2 If account number starts with 38 and the amount and text matches with another line item for which account number starts with 00, then I want the output to be the first number (ENTYrh400006ABC).

3. The dots in text data mentions any random data that will be present.

Can this be accomplished if we have lot of data.

Please let me now if you have any questions.

Sample Data:

 Ac No Desc Amount Text Output 00942 Out a ……………..ENTYrh400006ABCEN                /TYrd000008ABC……. ENTYrd000008ABC 38047 In a ……………..ENTYrh400006ABCEN                /TYrd000008ABC……. ENTYrh400006ABC 00943 Out b ……………..ENTYrh400007DEFEN                /TYrd000011DEF……. ENTYrd000011DEF 38048 In b ……………..ENTYrh400007DEFEN                /TYrd000011DEF……. ENTYrh400007DEF 00946 Out c ……………..ENTYrh500006ABCEN                /TYrd000078KLM……. ENTYrd000078KLM 38049 In c ……………..ENTYrh500006ABCEN                /TYrd000078KLM……. ENTYrh500006ABC
Highlighted
Alteryx

Try this out.  I think it matches your desired output, but not sure about edge cases (can there be singletons?  Multiple Matches?)

Here we are setting groupby fields and leveraging Conditional Formulas with RegEx to generate the desired output.

``````IF [Text]=[Row-1:Text] && [Amount]=[Row-1:Amount] && toNumber(Substring([Ac No],0,2))=38 THEN
REGEX_Replace([Text], ".*ENTY(.{11}).*", "ENTY\$1")
ELSE
REGEX_Replace([Text], ".*\/TY(.{11}).*", "ENTY\$1")
ENDIF``````

Highlighted
5 - Atom

Need output as in the snapshot only

Highlighted
7 - Meteor

Let's say they are grouped and the logic works for them. Now, how to include the logic such that even below works for those which are not grouped (unique ones)

 38050 In d ……………..ENTYrh500067ABC……. ENTYrh500067ABC
Labels