Filter datatable not using if or for each

Hi @yash.choursia ,

A bit of a confusion with what is the Datatable1 and Datatable2. But eventually we should be able to perform the below steps :

  1. Get the invoices values as Array of String from the Datatable which contains only 1 column Invoices. We can do it in the below way :
invoicesList = DT1.AsEnumerable.Select(Function(x)x("Invoices").ToString).ToArray

Here, invoicesList is a variable of Type Array of String.

  1. Next, we can filter the DT2 with the invoices available in the created list like below :
DT2 = DT2.AsEnumerable.Where(Function(x)Not invoicesList.Contains(x("InvoiceNo.").ToString)).CopyToDatatable

DT2 is the datatable that is having the columns as provided in your screenshot

Direct Conversion to Datatable after Filter could result in Errors, we could handle it in the below manner :