Filtering Datatable Column with another Datatable Multiple Columns with Linq


I need some help with the Linq datatable filtering. I am struggling with step 2 Linq coding which I couldn’t find a similar scenario in the forum.

Below are the steps:

  1. I have the code to filter DT2 where the “Robot Use” column is not empty then I will be left with Row 2 & 3 in DT2.

DT2.AsEnumerable.Where(Function (row) Not String.IsNullOrEmpty(row(“Robot use”).tostring)).copytodatatable()

  1. Filter DT1 Vendor and Document Currency with DT2 Vendor and Document Currency then I should get something on the “Final DT1 result” (refer to image)

  2. Then I will need the Document Number and Amount in doc curr for other purposes.

Thank you in advance.


Hope the following helps you.

dtResult = DT1.AsEnumerable.Where(Function(r) filteredDT2.AsEnumerable.Any(Function(r2) r("Vendor").ToString=r2("Vendor").ToString AndAlso  r("Document currency").ToString=r2("Document currency").ToString)).CopyToDataTable (7.9 KB)


1 Like

Thank you so much. It works exactly what I describe. :grinning:

1 Like

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