Match same data table columns against each other

I have column1 and column 2 in Data Table which contains strings. I want to match column1 against column2 in same data table and I need output in column3 as Found is both are matching and if 1 column is blank it should reflect not found and if not matching results should not matching

Hi @Sucess_for_Everyone

Can you provide sample input and expected output.

Meanwhile you can try the below code in Invoke Code activity

=> Read Range Workbook
Output-> dt

dt.AsEnumerable().ToList().ForEach(Sub(row)
    row("column3") = If(String.IsNullOrEmpty(row.Field(Of String)("column1")) OrElse String.IsNullOrEmpty(row.Field(Of String)("column2")), "Not Found", If(row.Field(Of String)("column1") = row.Field(Of String)("column2"), "Found", "Not Matching"))
End Sub)

In Invoke Arguemnts give In/Out pass dt.

Regards

Hi @Sucess_for_Everyone

Try this

dt.AsEnumerable().ToList().ForEach(Sub(row) row("column3") = If(row("column1").ToString.Trim() = row("column2").ToString.Trim(), "Found", If(String.IsNullOrWhiteSpace(row("column1").ToString) OrElse String.IsNullOrWhiteSpace(row("column2").ToString), "Not Found", "Not Matching")))

Regards,

1 Like

@Sucess_for_Everyone

You can try this in invoke code and send dt as in/out variable

Dt.AsEnumerable.ToList.ForEach(sub(r) r(2) = If(String.IsNullOrEmpty(r(0).ToString) OrElse String.IsNullOrEmpty(r(1).ToString),"Not Found",If(r(0).ToString.Equals(r(1).ToString),"Found","Not Matching")))

Cheers

1 Like

Thanks for quick response… will check this

1 Like
  • For Each Row in Data Table
    – Else If
    — CurrentRow(“Column1”).ToString = CurrentRow(“Column2”).ToString
    ---- Assign CurrentRow(“Column3”) = “Found”
    — Else If IsNullOrEmpty(CurrentRow(“Column1”).ToString)
    ---- Assign CurrentRow(“Column3”) = “Not Found”
    — Else
    ---- Assign CurrentRow(“Column3”) = “Not Matching”

Thank you it works for me… I tried all solutions provided to me and all are working… thank you all

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