Nested for each. Two Datatables. How to assign row values?

Hello community!

I am new to UiPath and with limited experience with so right now I am having trouble assigning the row values from a DataTable in a for each activity nested in another for each for a different DataTable.

What I want to perform is:

For each item in DT1:
do For each item in DT2:
do Assign DT1.column(“Color”) = DT1.Column(“Color”) + DT2.Column(Color)

I want to do this in order to attach the each color code in DT2 to each row in DT1.
I am open to a better approach.
I do not know the syntax on how to call the datatable columns/rows when you are interacting with two at the same timen. When I do a simple for each in a DT is simpler, like Assign: row(“Output Column”) = row("Input Column)

Thank you very much in advance.

1 Like

@andres.santos You can use DT(rowIndex)(columnIndex) = DT1(rowIndex)(columnIndex) or
DT(rowIndex)(“columnName”) = DT1(rowIndex)(columnName) or
DT.Rows(rowIndex).Item(“columnName”) = DT1.Rows(rowIndex).Item(“columnName”)

These are ways you can Access values in a Datatable , I hope this is What you needed :sweat_smile:

1 Like

Should be like this I guess…

For each item1 in DT1:
do For each item2 in DT2:
do Assign item1.column(“Color”) = item1.Column(“Color”) + item2.Column(Color)




1 Like

I am having trouble defining rowIndex. Where does that value comes from?
Thank you for your quick reply.

This was my issue. I was not defining the items for each DT.

Thank you very much!!



eg: consider these are coulumns in excel||Name || father’S name||
0 1 2 index is 0,Name index is 1 and fathers name inex is 2
hope this helps

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