Alteryx Designer Desktop Discussions

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

Match Data Based on the column value

geeklarokcmie
8 - Asteroid

Hello Experts,

 

Currently my input data has the below four columns.

I'd like to ensure whenever there is NC and 7numeric values next to it in columns description and summary - it should result out in a new column with KEY values or say No Match.

 

Input Data :

ProjectKeyDescriptionSummary
RailwaysRL-1567Priority tickets to be incorporated NC5847865 tag and include
EngineeringEG-2564Inclusion of NC8745624process files within NC8745624
ScienceSC-6598Fix Data NC9875452terminatedteamhasidentity
HistoryHS-0258corporatedata into asssement incorporatedfix missing field NC0254563
EnglishEG-7896process not workingprepare test for NC9965523
MathMATH-4569set up incidents of processlake streaming with details in NC0245635

 

Expected Output:

ProjectKeyDescriptionSummaryResults
RailwaysRL-1567Priority tickets to be incorporated NC5847865 tag and includeRL-1567
EngineeringEG-2564Inclusion of NC8745624process files within NC8745624EG-2564
ScienceSC-6598Fix Data incorporatedterminatedteamhasidentityNo Match
HistoryHS-0258corporatedata into asssement incorporatedfix missing field NC0254563HS-0258
EnglishEG-7896process not working NC9965523prepare test inclineEG-7896
MathMATH-4569set up incidents of processlake streaming with details No Match
5 REPLIES 5
DataNath
17 - Castor

Hey @geeklarokcmie, we can use RegEx to look for certain string patterns so I went down the route of checking if there's a match of NC followed by 7 numerics with the following approach. Only thing is the last record in your scenario above - according to the logic this should pull the [Key] through but you have 'No Match' in your expected output - is this an error?

 

1414.png

aatalai
14 - Magnetar

Hi that could be done wiht the formula tool and regex match

 

If regex_match([description],".*NC\d{7}.*") or regex_match([Summary],".*NC\d{7}.*")  then [Key

 

else "No match" endif

geeklarokcmie
8 - Asteroid

@aatalai & @DataNath - Thank you so much for prompt response. Both your forumla worked the way I wanted it to. ^_^

AmitMiller
Alteryx
Alteryx

Hi @geeklarokcmie, thank you for your question!

Do note -

  1. your "expected output" is different from your "input data" in lines 3,5,6. This is why DataNath asked about an error
  2. make sure you check both columns. You've written "in columns description and summary", but it looks like you meant or - since that's how you've implemented it. So that's how we refer to it =]
  3. If you want to be pedantic, and make sure there are no more than 7 digits - do let us know, as it will require a bit more tinkering.

 

Now, important to notice - the two excellent answers above utilize different functions.

  1. Regex_match - which needs to match the entire field. That's why padding the pattern with .* (any character, repeated unlimited times) is needed
  2. Regex_countmatches - This counts the number of times the pattern was matched (=found) in the field. Hence, doesn't need the .* padding.
    1. This is also why a ">0" was added - as you need to make sure you've found at least one match

Having said all that - attached is a solution that takes both approaches into account:

result creation.pngnotice that I didn't write ">0" in the countmatches option - that's due to it either being 0 or 1. A logical expression that equals 1 is evaluated as True. Should work for all values bigger than 0

 

Hope that helps!

geeklarokcmie
8 - Asteroid

@DataNath I completely missed the part where the input data columns for summary and description were not as same as output data. I should have corrected that before posting. Appreciate your solution as it worked. 

 

@AmitMiller Appreciate the clarification and providing two different solutions along with the reasoning. I will run your workflows to understand  how it satisfies my data requirements. 

Labels