Comparing two datatables with common id

I have two product lists that I have imported into two separate datatables. One new (dt1) and one old (dt2). They each contain just two columns: article number and price. I want to find (save to new Datatable (dt3)) the products with a price change. I can’t figure out how to do this in an efficient way. The files are thousands of lines.
The sorting of the two databases may be different and there may be some products that does only exist in one of the files. In such case I want to threat this as a price change, hence be present in the dt3. Please help!

Task is solveable, with essential UiPath elements, with LINQ, maybe with some custom libraries or with the combination of all from above.

In case of you need more inputs or implementation help, so just provide some sample data covering all requirements for to take into place. We can will help you on the implementation

1 Like

Try this logic -

For Each Row in dt1 (lets call this dt1Row)
Filter Data Table dt2 like this

If tempDT.Rows.Count = 0 then there article number is not there in dt2. You can add that to dt3.
If tempDT.Rows.Count = 1 then get the price from tempDT.Rows(0).item("Price") and compare with dt1Row("Price"). If this is not equal then add to dt3.

Once the loop is complete you can export your dt3 to check your results.

If you want to compare items that are in dt2 but not in dt1, you need to do this -
For Each Row in dt2
Filter Data Table dt1
If tempDT.Rows.Count = 0 then there article number is not there in dt1. You can add that to dt3.

Hope this helps!
You can also use Lookup Data Table activity instead of Filter Data Table activity.

Hi! Do you think Lookup would be more efficient?

Thank you so much for the suggestion! I will look in to this later today.

In your scenario, I dont think it makes much difference.Wanted to let you know a possibility if you were comfortable with using lookup

PFA a standalone demo xaml showcasing joining for getting the commons and set operations to identify differences
Just take it a playground for mixing up the different set combinations and also to get test with the mass data from your end.

Here it is: HenrikX.xaml (12.2 KB)
Let me know your feedback and open questions


Thank you so much!!

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