Get non matching rows from dt

Hi Experts,

Good day. I need solution for the below problem.

i have two datatables called dt1(Loan buyers records) and dt2(Loan closed list). by comparing the two datatable, i want to find (loan not closed list) means record which is not present in the dt2 by comparing the dt 1

attached sample record:

Thanks for your attention on this matter

cheers

Hi @vigneshn

Try this.

dt_UnCommonRows = dt1.AsEnumerable().Except(dt2.AsEnumerable(),System.Data.DataRowComparer.Default).CopyToDataTable

Hope it helps.

this is not working as expected

where we need to mention the column ID or column name in the above query

This query compares the whole row. You just need to input datatables.

Here you can mention the column name:

UnnMatched_Data = dt1.AsEnumerable().Where(function(row) Not dt2.AsEnumerable().Select(function(r) Cint(r(“ID”))).Any(function(x) x = Cint(row(“ID”)))).CopyToDataTable()

Getting the below error mate

Assign: Expression Activity type ‘VisualBasicValue`1’ requires compilation in order to run. Please ensure that the workflow has been compiled.


assign activity value

This is one more where you convert ID column of one datatable to array and comapare with other.

dt2_Array = dt2.AsEnumerable().Select(Function (a) a(“ID”).ToString).ToArray()

dt_Output = (from s in dt1.AsEnumerable where Not dt2_Array.contains(s(“ID”).ToString) Select S).CopyToDatatable()

I have updated the code. Please check now.

Same error :frowning:

Hi @vigneshn Can you try the below query

var of type DataTable Output = DT1.AsEnumerable.Where(Function(x) Not DT2.AsEnumerable.Where(Function(y) x(1).ToString.Equals(y(1).ToString)).Any).CopyToDataTable

Check below workflow for ref

DT.zip (2.9 KB)

1 Like

Thanks !! you are great :slight_smile:

1 Like

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