Compare two datatables and get unique value from dt1

Hi,

I am facing one problem,

I have two dt
dt1 -
ID
1
2
3
4
dt2-
ID
4
5
6

I just want rows present in dt1 but not in dt2.

Hey @Sahil_Garg1

Left join using Join Data Table activity would be a good option to go with.

Thanks
#nK

dt1.asEnumerable.Except(dt2.AsEnumerable, DataRowComparer.Default).CopyToDataTable

1 Like

Hello @Sahil_Garg1

The below expression will give you the result.

DT1 and DT2 are the 2 datatables.

1 Like

can share one test flow

@Sahil_Garg1

Plz watch the below video…If you want both similar you can use Intersect and only rows from Dt1 then use Except.

In case that an empty result is also to expect the copytodatatable can be defensive handled as described here:

:ambulance: :sos: [FirstAid] Handling of The source contains no DataRows exception - News / Tutorials - UiPath Community Forum

1 Like

It is return no rows,

It is giving incorrect result as i want 1,2,3 but it is including 4 also

is data exact as the 1 column structure data from the description above or is another dataset is used e.g. with more columns?. Can you show the used test data?

Test.xlsx (9.0 KB)
Yes, only 1 col is there ID

find some demo / starter help here:
DataTable_SetOperations.xaml (8.9 KB)

kindly note: Except / set operation operators are using the entire row for the check (so 2,n cols were also working with the same command).

We will soon run it with your data

1 Like

Hi @Sahil_Garg1,

When I check it it gives correct result.

Test.xaml (5.6 KB)

Regards,
MY

it was working, can you please share some details of your implementation? Thanks

Buddy,

I test data which i shared with u, i want out of rows 1…25, which are unique in dt1.

I have done it through loops and complex conditions but just looking if any query can do it to make it faster

Main.xaml (5.9 KB)

my bad, just doing one silly mistake got it now.

Thanks everyone for quick responses

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