I’m try to merge two dt Like below ScreenShot
Please follow the below approach:
ARow("Col1").ToString = BRow("Col1").ToString
This is a simple way to achieve this. You can also use counter logic to filter rows from both data tables and then use the results to frame a new output data table.
To merge two data tables in UiPath, you can use the Merge Data Table activity. This activity allows you to merge two data tables by specifying the data table to merge and the data table to merge into, as well as the columns to use for the merge.
Here’s an example of how you can use the Merge Data Table activity in a UiPath workflow:
You can also use the Merge Data Table activity to specify the type of merge to perform (e.g. inner, outer, left, right), as well as the columns to use for the merge key.
Reference Link: https://docs.uipath.com/activities/docs/merge-data-table
Hope the following sample helps you.
dtA = dtA.AsEnumerable.Zip(dtB.AsEnumerable,Function(r1,r2) dtA.Clone.LoadDataRow(r1.ItemArray.Zip(r2.ItemArray,Function(v1,v2) if(String.IsNullOrEmpty(v1.ToString),v2,v1)).ToArray,False)).CopyToDataTable
Sample20221222-3aL.zip (2.9 KB)
you can use For Each Row to iterate through DataTable A and then use .select to find the matching row in DataTable B:
DataTable B.Select("Col1 = ’ “+row.item(Col1)+” ’ ")(0)(“Col2”) → this should give you the value in Col2 in DT B in the same row as in DT A. Now you need some if conditions, which value you want to have.
what to update in Col3 for Result table, when there is data in Col2 of both of the table (DataTable A and DataTable B)…?
Actually there is no way both cell have value
So no worry about it
Merge Data Table cannot handle my problem
check @Yoichi’s solution, I think that will work for you.
Thank you! you really help me a lot ^^
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.