Ho to check compare two Datatable and remove matching from one datatable

Hi All,
could you please let me know how to do below scenario in UiPath ,

I have -
datatable 1 - new list
dataTable 2 - existing list

if datatable 2 - Document number (Column) match with datatable 1 document number(Column)

if column status in Dt2 = Success if yes

remove that in row from datatable 1

once done - write new updated rows in to new datatable

@monisharpa2020,

Try using this LINQ in Assign activity

newDataTable = DataTable1.AsEnumerable().Where(Function(row) Not (
    DataTable2.AsEnumerable().Any(Function(existingRow) 
        existingRow("DocumentNumber").ToString() = row("DocumentNumber").ToString() AndAlso 
        existingRow("Status").ToString() = "Success"
    )
)).CopyToDataTable()

Thank you, it worked!

1 Like

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