Combined data tables with no reference column

Hello there. I have three data tables. I want to combined them to a new datatable for my further handling. I tried Join & Merger datatable function but they didn’t work because there’s no common column for matching.

Thank you for your help. I have attached the picture for your reference.

Removed: Approach was changed

Having checked the output table the user wanted, I don’t think it is what I want…
Please note that in my desired output, there are only four rows.

Removed: Approach was changed

HI ppr, I was trying this but encountered some difficulties. Firstly, your example is only for two data tables. Does it mean I should first do it with dt1 & dt2 for a desiredDT, then do it with desiredDT & dt3 for new desired DT?

Moreover, it’s showing the error when I used the invoke method activity.
image

Removed: Approach was changed

Ok, I tried it with dt1 and dt2. The output is indeed a lot more than 4 rows. Just like what I mentioned earlier. I don’t need 4 rows of each name. Could you please advise?

image

Removed: Approach was changed

Hi Peter, could you see the photo already attached in the first post? It showed the 3 data tables on top and the desired output I want below on the same photo.

Please let me know if you couldn’t see it. Thank you.

Removed: Approach was changed

Yes, as showed in the photo, only four rows in DT1, excluding the header.

Name Age Nature
Funny 25 Combine
Studio 26 Other
Question 36 Fine
Data 13 Thank

Could you please share the xaml file on how you do it?

i guess I got it. Let’s shift to another approach. Give us please some time for this.

Could look like this:

  • merge the structures dt1,dt2,dt3 - targetDT
  • (assumed all tables will have the same rowcount
  • iterate over first dt1, use loop index to pick up the rows from the other tables
  • add combined RowArray to the targetDT
1 Like

Hi Peter, thank you in advance! Yes, all data tables will have the same row count

@wth1993
With the constraint that all datatables have the same row count here we go:
Variables:
grafik

Preparing dtResult by Merging all DataColumn Structures:
grafik

Doing the Merge / Combination

Result:
grafik

As an alternate it can be done with a LINQ:
Merging we do the same way as above (dtResult was cloned therefore)
grafik

Find starter Help here:
MergeDataTables_SideBySide.xaml (17.2 KB)

1 Like

Thank you very much, Peter! It works perfectly!

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