Compare 2 dts with partial match values

dt1 dt2 result
John Tan Jun Chen John Tan match
Alvin Wong Alvin Wong from.NCS match
Lilian Lee Lilian Lee match
Chua Ah Bee Ah Bee Chua match
Steven Lim Michelle Lim not match

Hi all, how do I compare the 2 columns from 2 different datatables with partial match like the example above.

@sophiey

’ Assuming dt1 and dt2 are the two DataTables to be compared

use this Linq

From row1 In dt1.AsEnumerable()
From row2 In dt2.AsEnumerable()
Where row1.Field(Of String)(“Column1”).Contains(row2.Field(Of String)(“Column2”))
Select New With {
.Column1 = row1.Field(Of String)(“Column1”),
.Column2 = row2.Field(Of String)(“Column2”)
}

@sophiey

can you provide sample input and expected output

Hi @sophiey ,
we have 2 popular ways are
1.use activity ‘for each row’ dt1 inside ‘for each row’ dt2
and ‘if’ row = line
→ assign value result
2.use linq
regards,

as the order of the tokens is changed it is different from a contains check

In such cases we recommend

  • check if token split and its completness check will serve the requirements
  • check if a particular string similarity algorithm is reflecting your requirements

Hi @sophiey ,
Thanks for reaching out to UiPath Community.

You can try these steps to achieve the solution you need.

  1. Create a new DataTable result to store the comparison results.
  2. Use For Each Row loops for both DataTables:
  • For each row in dt1, you will iterate through each row in dt2 to compare them.
  1. Perform Partial Matching:
  • For each row in dt1, iterate through each row in dt2 and compare the values. You can use string methods like Contains, IndexOf, or regular expressions to check for partial matches.
  1. Add a Row to result DataTable:
  • When a match is found, add a row to the result DataTable with the corresponding values and match status.

Thanks,
@pratik.maskar

Hi @sophiey ,

Could you maybe check with the below workflow :
DT_UpdateResult_BasedOnNameMatch.zip (9.4 KB)

Below is the Implementation done :

Let us know if it fails for any of the sample test strings and do provide us the failing strings so that we can correct the logic if needed.

The Logic used is - The Length of the String could be taken into consideration to identify the shortest length string, Then We would need to check whether all the words of the shortest string exist in the Other String and if so, it counts as a Match else Not Match.

Note: Here case insensitive is considered when comparing strings.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.