Comapre data to an excel sheet

how to compare the 2 data from the build table activity and save it in an excel sheet. the datatable some have the same data but place in a different order, i want it to have all the data from the 2 tables. also, the column name is different so do it so that the column name would be the same.

give me the solution please

ID Name Age
1 Ryan 19
2 joshua 23
3 chloe 35
4 poh 2
5 Ben 54
this is how the output will be like

@Ryan_Lee,

Share the desired result you are looking for out of these 2 datatables.

Hi @Ryan_Lee ,

Could you Try this linq query.

DT1.AsEnumerable.Where(Function(x) Not DT.AsEnumerable.Select(Function(y) y(“Name”).tostring).ToArray.contains(x(“FullName”).tostring)).CopyToDataTable.AsEnumerable.Select(Function(x) DT.Rows.Add(x.ItemArray)).CopyToDataTable

DT - Your 1st Data Table
DT1 - Your 2nd Data Table

Thanks!

ID Name Age
1 Ryan 19
2 joshua 23
3 chloe 35
4 poh 2
5 Ben 54

Hi @Ryan_Lee ,

This expression will give your expected output.

DT1.AsEnumerable.Where(Function(x) Not DT.AsEnumerable.Select(Function(y) y(“Name”).tostring).ToArray.contains(x(“FullName”).tostring)).CopyToDataTable.AsEnumerable.Select(Function(x) DT.Rows.Add(x.ItemArray)).CopyToDataTable

can u show me the solution instead so that i can better understand it

Iterate DT1 (2nd data table) each item and checking whether that item is available in DT (1st Data table).

What are the iterated items (DT1)are not available in the DT, those items are carried as data table. Consider as TempDT(Which has unmatched records of DT)

TempDT = DT1.AsEnumerable.Where(Function(x) Not DT.AsEnumerable.Select(Function(y) y(“Name”).tostring).ToArray.contains(x(“FullName”).tostring)).CopyToDataTable.

Then. Iterate TempDT and add into the existing datatable DT. This is your output Datatable

AsEnumerable.Select(Function(x) DT.Rows.Add(x.ItemArray)).CopyToDataTable

You will get your expected output with combination of this 2 expressions.

DT1.AsEnumerable.Where(Function(x) Not DT.AsEnumerable.Select(Function(y) y(“Name”).tostring).ToArray.contains(x(“FullName”).tostring)).CopyToDataTable.AsEnumerable.Select(Function(x) DT.Rows.Add(x.ItemArray)).CopyToDataTable

Thanks!