Compare the rows in the downloaded DataTable with those in the master DataTable. If there are identical rows in the master DataTable, I intend to remove those corresponding rows from the downloaded Excel file and retain only the unique records

I have two Excel files from which I’ve read data into two separate DataTables: one serves as the master DataTable, and the other represents the downloaded DataTable. Now, my objective is to compare the rows in the downloaded DataTable with those in the master DataTable. If there are identical rows in the master DataTable, I intend to remove those corresponding rows from the downloaded Excel file and retain only the unique records.

we can compare both datatables with column Spool .

if spool number is there in master excel then we have to ignore it only rows whose spool is not there in master excel should me there in the datatable.

Please Help

Hi @ravig1206

Input:-
inputDt:-
image

MasterDt:-

Output:-
image

Xaml File:-

compare 2 dt and find unique rows.zip (3.6 KB)

If this works for you, then please mark this as a solution. So others can refer the same.

Thanks

1 Like

Thanks for your reply.
But here you are checking whole table.
I want to put check on one column value and if it matches the remove it from the downloaded dt.
it is because the columns are not stable they can increase or decrease.

Hi @ravig1206

You can do it using the mentioned LINQ.

dtUniqueData = DataTable1.AsEnumerable().Where(function(row) Not DataTable2.AsEnumerable().Select(function (r) r.Field(Of String)(“ColumnName”)).Any(function(x) x = row.Field(Of String)(“ColumnName”))).CopyToDataTable()

Thanks

Happy Automation! :smiley:

Note: Please check the Parenthesis once, they might be off a bit.

1 Like

Thanks Adiijaiin It worked

1 Like

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