Combination without repetition. 4 columns from 2 DataTables

Hello everyone!

I am having a bit of trouble with the following logic:
I have a DT1 with some columns out of which I have to modify two with the information from another DT2 with same columns but different values.
I have to perform a combination of each value in DT1.columnC1 with:

  1. its own value > DT1.columnC1+DT1.columnC1 and DT1.columnC2 remains the same
  2. with the value from DT2 > DT1.columnC1+DT2.columnC1 and DT1.columnC2+DT2.columnC2

I tried doing a nested for each but I did not take into account that it will perform the action of the nested DT2 over the same row of DT1 that its processing in each iteration having at the end all the codes from DT2 concatenated as I want it for each row of DT1 in the same row instead of being in NEW rows for each row of DT2. I have attached a pic for visual clarification. And when i tried adding a new row in each iteration it failed with the enumeration error.
I want to keep the rest of the columns from DT1 if possible.
What can i do without using code and only using the prebuild UiPath commands?

For reference, the rows on DT1 could be in the order of tens and the rows in DT2 just a few ones.

Thank you in advance!
Cheers,
Andrés

@andres.santos Are DT1 and DT2 the Input Datatables and The Table to the Right Side of the input Datatables Is it the Output Datatable?

Also I didnt get this Condition :sweat_smile:

  1. its own value > DT1.columnC1+DT1.columnC1 and DT1.columnC2 remains the same
  2. with the value from DT2 > DT1.columnC1+DT2.columnC1 and DT1.columnC2+DT2.columnC2

@supermanPunch Yes, DT1 and DT2 are the input tables and DT1 (ideally) is the output table. Dont mind if i have to create another DT to fill in the values.

the condition is that each element of DT1 has to be combined with itself and each item from DT2 as in the pic, so creating as many new lines as combinations possible.

@andres.santos Is it Possible to send the Excel Files ?

@supermanPunch I can send you the filtered data that needs to be transformed and the output. Just give a bit of time.
Than you very much for your support :smiley:

@andres.santos I need the Input Files though :sweat_smile: , I think I got an Idea Of the Output but you can provide that as well

Hey @andres.santos

Here you go:
CombineDatatables.zip (20.7 KB)

Happy coding!

@supermanPunch here are the files. as you can see the output has more items that the inputs because of the combination
Input.xlsx (10.4 KB) Output.xlsx (11.5 KB)

@andres.santos Check if this is What you wanted
CartesianProduct.zip (16.5 KB)

Also your Output File Didn’t include the Combination of 3V , Is it supposed to be like that? Also your Input Sheet DT2 had New Lines present in the Column Text Value, I thought it was a Typo and Replaced it manually. Then I got a Clear Output. Hope this is What you needed :sweat_smile:

1 Like

Thank you very much!
This is the solution.

Happy to help. :slight_smile:

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