{{ transformations:MatchAction.png}}
====== MATCH ======
Category: Transform / Advanced\\

\\ 
=====Description=====
This action goes through text values in the source table and finds matching values in a second "lookup" table (lookup table). Matched lookup values then replace original values.

\\ 
=====Use cases=====
  *The //Fuzzy// mode of this action can be used to match text values that may have typos.
  *This can be used for keyword detection in customer support tickets.
  *This action can be used for flagging fraud detection phrases in financial institutions.
  *Content moderation/spam detection in social media platforms.
  *Categorize products for an e-commerce site by converting long names to keywords within the names.
  *Log file analysis for IT & Security by flagging keywords in system and network logs.
  *Flag competitive brand names within customer comments.

\\ 
=====Action settings=====
^Setting^Description^
|Column|Select the column in the current dataset that contains the values to match in the lookup table.|
|Lookup table|Select the dataset to be use for the lookup.|
|Lookup column|This setting appears once the //Lookup table// has been selected.  Select the column that contains the values\\ to be matched to.|
|Match mode|Options: //Contains//, //Starts with//, //Ends with//, and //Fuzzy//.  See the table below.|
|Case sensitive match|When checked, text case must match in the lookup values.|
|If not matched|Choose how unmatched values are handled.  Options: //Keep existing value//, //Make empty//, or //Default to// (and choose\\ whether this value is an expression, or text or a number, and enter the expression or text/number value).|
\\ 
====Match mode settings====
^Mode^Description^
|Contains|A lookup value is returned if the source value contains it. For example, "tor" would be returned if the source value\\ was "Mo__tor__ola".|
|Starts with|A lookup value is returned if the source value starts with it.  For example, "Moto" would be returned if the source value\\ was "__Moto__rola".|
|Ends with|A lookup value is returned if the source value ends with it.  For example, "rola" would be returned if the source value\\ was "Moto__rola__".|
|Fuzzy|A lookup value is returned if the source value is within the specified //edit distance//.\\  The [[https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance|Damerau–Levenshtein edit distance]] measures the number of edit operations required to produce one word\\ from another.|
|Max. edit distance|This setting appears when the //Match mode// is set to "Fuzzy".  Choose the edit distance used by the Fuzzy-matching\\ process.  See the //Fuzzy// mode, above.|

\\
=====Remarks=====
In the case of multiple matches, an arbitrary match is taken (in no particular order) and other matches are ignored.

\\ 
=====Examples=====
====Example #1====
>Flag and categorize potential issues within customer comments.

===Before (source table)===
Table 1: Table of customer comments.
^Comment^
|Item arrived broken.|
|No comments.|
|My order is late again!|

Table 2: Lookup table
^Issue list^
|refund|
|late|
|broken|

===After (result table)===
^Comment^
|**broken**|
|No comments.|
|**late**|

===Action parameters===
>Column: Source text (Table 1)
>Lookup table: Table 2
>Lookup column: Issue list (Table 2)
>Match mode: Contains
>If not matched: Keep existing value

\\
====Example #2====
>Flag and categorize potential fraudulent transactions in a financial institution.

===Before (source table)===
Table 1: Text value to match.
^Transaction summary^
|Wire transfer to unknown receipient|
|Mobile check deposit|
|Scheduled transfer from checking|

Table 2: Lookup table
^Fraud flags^
|lottery|
|wire|
|gift card|

===After (result table)===
^Transaction summary^
|**wire**|
|Mobile check deposit|
|Scheduled transfer from checking|

===Action parameters===
>Column: Source text (Table 1)
>Lookup table: Table 2
>Lookup column: Fraud flags (Table 2)
>Match mode: Contains
>If not matched: Keep existing value

\\
====Example #3====
>Return a Lookup value contained within the Source text value.\\

===Before (source table)===
Table 1: Text value to match.
^Source text^
|Motorola|

Table 2: Lookup table
^Lookup values^
|tor|
|Moto|
|rola|
|Motrola|

===After (result table)===
^Source text ^
|**tor**  |

**Action parameters:**
>Column: Source text (Table 1)
>Lookup table: Table 2
>Lookup column: Lookup values (Table 2)
>Match mode: Contains
>If not matched: Make empty

\\ 
=====Community examples=====
  * [[https://community.easymorph.com/t//1551/2|How to look up and replace a string of text]] ([[https://community.easymorph.com/uploads/short-url/dvCtD7gg0AHUtXZ7tmQmuHflSYU.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //Table 3//; Action position: //3//)
  * [[https://community.easymorph.com/t//1817/5|Substring Query]] ([[https://community.easymorph.com/uploads/short-url/sUDlB2uHCazeCdBqFSik6tCvu9r.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //Table 1//; Action position: //3//)
  * [[https://community.easymorph.com/t//1849/4|Iterate through a set of column]] ([[https://community.easymorph.com/uploads/short-url/5icrGfTGgzbmG2l5AuSiqb43QvR.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //in.csv//; Action position: //5//)

\\ 
=====See also=====
  * [[transformations:lookup|Lookup]]
  * [[syntax:functions:contains|Function syntax: Contains(textA, textB)]]
  * [[syntax:functions:startswith|Function syntax:  StartsWith(textA, textB)]]
  * [[syntax:functions:endswith|Function syntax:  EndsWith(textA, textB)]]
  * [[syntax:functions:distance|Function syntax:  Distance(textA, textB)]]
