Compare two tables and add column

Hi,
I have two tables which I need to compare. If they have same rows in column A then I need to add data from the second to the first row for each row they match ID. In second table there are always new values (new ID and and new values) which also need to be added.

Table1:
image

Table2:
image

Table1 should look at the end like this:
image

give a try on Join DataTable (Join Type: full Join)
and adopt afterwards the Join Result (datacol adoptions, Empty value formats …)

Could you please explain? And there are only inner, left and full join type

yes full join (aka outer join)
Have a look here:

But it adds all the columns and I need to add only values and not the ID column

this we can cleanse afterwards very easy

Could you explain how or give me an example?

Sure, Lets suggest following:
You will create a XAML with two build datatables (dt1,dt2) along the demo data from above
We will pick up your XAML and enhance it for demo example

data.xlsx (12.8 KB)

Any idea???

please give me little time. Your excel differs from screenshot data as there are IDs in dt2 not present in dt1. So we have harmonize the join result

like this:


dtJoin.AsEnumerable.Where(Function (x) String.IsNullOrEmpty(x(“ID”).toString))
dtJoin.DefaultView.ToTable(False, {“ID”,“A”,“B”,“Column1”,“C”,“D”,“Column2”,“ASD”})
Result:
grafik

Feel free to enhance by:

  • “0” instead of Blanks
  • any orderings

Find starter help here:
Demo_JoinDataTable.xaml (9.8 KB)

And could you please give me an idea when the robot does this every month?
So after the dtResult is created I write two more columns with formulas, then the next month robot needs to read that datatable and do the same thing by adding column with new data

On the first view it looks that it should be handleable by enhancing it with some dynamics (e.g. column array for the dtResult.Select etc.

We would suggest to keep the topics clear on case and in case of further open questions open a new topic on this new case. It would help if sample date for the two months are proivded. Thanks

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