Datables operations = keep not matching values


I have logic problem which I cannot resolve.
I have two datables with number values.
Let`s say:





I want to keep in new datable result, when searched value from dt.A is not present in dt.B, but, i`m not sure how to do this. When im joing datables with operation not equal(!=)

output will be like:

coulumn1-dt.A coulumn2.dt.B
111 - 333
111 - 444
222 - 111
222 - 333
222 - 444
333 - 111
333 - 444

And well thats correct result, because when its comparing(!=) “111” from dt.A with “444” from dt.B it will be true 111!=333 and then i will get that recorded added to my new DT . What i want to aquire is:


dt.A(value not present in dt.B)
222 (only 222 because value not found in dt.B)

Maybe it`s simple, but i just stuck here and cannot go on :<

Thank you from above

Hi @Add_Bddd ,

Correct me if I am wrong, but you want to create a DataTable where the values in DtA are not present in DtB right?

If that is the case, you can use a Group Join like so →

(From r1 In dtA.AsEnumerable()
Group Join r2 In dtB.AsEnumerable()
On [ConditionGoesHere] Into gj = Group
From g In gj.DefaultIfEmpty()
Where IsNothing(g)
Select r1).CopyToDataTable()

Kind Regards,
Ashwin A.K

1 Like

find starter help here:
GetLeftWhenMatchRight_1Col_AnyApproach.xaml (14.9 KB)
And post process it.

The join datatable activity allows us to achieve the result as well

1 Like

as an alternate approach we can do it with the help of a cartesian product


(From d1 In dt1.AsEnumerable
From d2 In dt2.AsEnumerable
Where Not d1(0).toString.Equals(d2(0).toString.Trim)
Let ra = New Object(){d1(0), d2(0)}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable

Find starter help here:
PairsWithTheUnmatched_1col.xaml (10.3 KB)

@ashwin.ashok @ppr
Thank you guys, working!

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