Compare DataTables to see if they contain the same values

Hi all

I’ll get two data tables and in each datatable, there will be a column with the same name called ‘Tickets’ in each table. It’s really important that both those columns contain the same data - same values/number of populated rows - everything the same.

If any of the data is different I don’t need to point out which data is different or anything like that - I will just throw a BE in the process for the customer to review the datasource - two tabs on an excel sheet :slight_smile:

@Palaniyappan I hope you don’t mind me tagging you in - you’ve very kindly answered plenty of my questions in the past, so seeing if you can (please) help?

Thanks in advance

1 Like

we can check with

  • join datatable activity
  • A LINQ Statement
  • Set Operations on Ticket Values

With some sample data from you we can suggest more individually the solution implementation


Welcome back to UiPath forum

Hope the below expression would help you resolve this
Use a If activity like this

(From DT1 In dt1.AsEnumerable() Join DT2 In dt2.AsEnumerable() On DT1(“Tickets”).ToString() Equals DT2(“Tickets”).ToString() Select DT2).ToArray().Count < Dt2.Rows.Count

Here we are trying to join two datatable and get the matched values of that Ticket column and see whether the count is equal to actual row count or not
If it’s same then all values of that column matches between two datatable
If not there is a difference between them

Cheers @jordrowley

Hey @Palaniyappan - thank you!

Does this also check the values so the below would be true as values in both columns match

Tickets Tickets
A3464 A3464
A5645 A5645
A3456 A3456

But this would be false as the values don’t match?

Tickets Tickets
A3464 B3464
A5645 D5645
A3456 A1111

Thanks as always

dt1.AsEnumerable.Select(Function (x) x("Tickets").toString.Trim.Intersect(dt2.AsEnumerable.Select(Function (y) y("Tickets").toString.Trim).Count = dt1.Rows.Count And dt1.Rows.Count = dt2.Rows.Count

we check here all common Ticket numbers and when this common ticket no count is also the same of dt1 and dt2 rows count we dont have any missmatches