Arrange data from other datatable based on minutes variance

I have 2 datatable, Datatable 1, has more rows than datatable 2, I want the data from datatable 2 is inserted into datatable 1 based on variance of minutes.

Datatable 1

Datatable 2

Expected Output

Expected Output is output from DT1 where data from DT2 is inserted into DT1

My Output

Workflow that I have done is as below
test1910.xaml (45.2 KB)

may we ask you to elaborate a bit more on your case. Thanks

Okay so I have 2 datatables that consists of Destination, Minutes, Rate and Amount. What I am trying to do is to match the lowest difference in minutes from DT2 into DT1 and the country from both datatable needs to be same. But, we only have 3 datarows from DT2, so the number of rows need to be entered into DT1 also 3 datarows.

we can handle this by a stack concept:

lets group dt2 data on the Destinations
Iterate over the groups
lets create some immediate helper stacks with the information of row indes and Minutes as double

as long we do have items on the stacks
find the closest match (done with an Match.Abs(d1Min-d2Min for getting the absolute diferrence)
Update the datarow from d1 with an modified ItemArray
remove found items from the Stacks

Loop watches:


find starter help here:
MergeClosestDiff_StackApproach.xaml (19.7 KB)

Wow this is the alternative way, I will learn this. Thank you for opening my eyes

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