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

Extract partial text from a field based on multiple conditions

Pranee_007
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 NoDescAmountTextOutput
00942Outa……………..ENTYrh400006ABCEN                /TYrd000008ABC…….ENTYrd000008ABC
38047Ina……………..ENTYrh400006ABCEN                /TYrd000008ABC…….ENTYrh400006ABC
00943Outb……………..ENTYrh400007DEFEN                /TYrd000011DEF…….ENTYrd000011DEF
38048Inb……………..ENTYrh400007DEFEN                /TYrd000011DEF…….ENTYrh400007DEF
00946Outc……………..ENTYrh500006ABCEN                /TYrd000078KLM…….ENTYrd000078KLM
38049Inc……………..ENTYrh500006ABCEN                /TYrd000078KLM…….ENTYrh500006ABC
3 REPLIES 3
PeterA
Alteryx Alumni (Retired)

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

 

 

Snag_1322fd7a.png

TirumalaKishore
5 - Atom

Need output as in the snapshot only 

Pranee_007
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)

 

 

38050Ind……………..ENTYrh500067ABC…….ENTYrh500067ABC
Labels