Invoke method not joining two datatables

I have two datatables , and I have to join dt1 with dt2. dt1 has 3 column and dt2 has columns.

the resulting dt should be having 4 column. I am joining on the basis of primary key and I have assigned first column as primary key in both dt1 and dt2.

the line items in first column of dt1 and dt2 are unique and same
Still Invoke method not able to join both datatable.
dt1-

INR million FY18 3/31/2018
Test40 0 0
inventories at the end of the year:1 0 0
finished goods2 300.1019267 222.105
work-in-progress4 231.2314402 180.679
stock-in-trade6 30.15119893 20.776
Test58 561.4845658 423.56
inventories at the beginning of the year:9 0 0
finished goods3 222.105 283.595
work-in-progress5 180.679 258.527
stock-in-trade7 20.776 16.25
Test610 423.56 558.372
net (increase) / decrease11 -137.9245658 134.812

dt2-

INR million FY17
Test40 0
inventories at the end of the year:1 0
finished goods2 283.595
work-in-progress4 258.527
stock-in-trade6 16.25
Test58 558.372
inventories at the beginning of the year:9 0
finished goods3 354.123
work-in-progress5 243.616
stock-in-trade7 29.629
Test610 627.368
net (increase) / decrease11 68.996
.

I have assigned first column of both datatables as primary key

I’d recommend using the ‘join data table’ activity instead.

If you need to use the .merge() method instead of the built-in activity, then what parameters are you giving it?

See more documentation on the .merge() method and how to use it here: DataTable.Merge Method (System.Data) | Microsoft Learn

1 Like

Join datatable will not give me the output i want , and per the definition of invoke method , It should give the result but its just giving me the error.

The output I want is

INR million FY18 3/31/2018 FY17
Test40 0 0 0
inventories at the end of the year:1 0 0 0
finished goods2 300.1019267 222.105 283.595
work-in-progress4 231.2314402 180.679 258.527
stock-in-trade6 30.15119893 20.776 16.25
Test58 561.4845658 423.56 558.372
inventories at the beginning of the year:9 0 0 0
finished goods3 222.105 283.595 354.123
work-in-progress5 180.679 258.527 243.616
stock-in-trade7 20.776 16.25 29.629
Test610 423.56 558.372 627.368
net (increase) / decrease11 -137.9245658 134.812 68.996

@Karan28

Check as below

You can use Join Datatable and can remove unwanted columns

Hope this helps you

Thanks

Hey no , that is not helping . I need both duplicate and non duplicate items after joining the datatable

Is it the “/” that is breaking the merge? Did you try testing it without the special characters?

Yes I removed this character and executed this again. Still same issue

I’m confused as to why the join datatable won’t work? Based on the input you showed us and your expected output, a join activity would work perfectly & there are already screenshots from @Srini84 showing the results. Perhaps you can share the actual inputs since they must be different from your picture? Or you could share the results of the join datatable activity which will help show why it isn’t working.

As for the datatable.merge() method - it has some quirks and especially within UiPath i try to avoid using it. I had asked what paramaters you were using because there are optional arguments to the method and knowing which parameters you provided would help troubleshoot. I have found the most common reasoning for the constraint exception is due to case sensitivity or modifications made within code to the column names or properties

EDIT: here is example using your own inputs from your post and it matches your expected output exactly… delete.xaml (8.6 KB)

All special characters or just the slash? Try it with clean strings on a sample and see if it fails. If it fails then perhaps you have syntax error in your code.

Otherwise you could do a left join using Join DT activity and then remove the columns you do not need.

Looks like reposted this issue, can you close this one? Based on other post, same advice but use Full join.

1 Like