MLT
(MLT)
April 19, 2021, 4:45pm
1
Hi,
I have two data tables
Datatable1
ID
Name
1
aaa
2
bb
3
cc
4
dd
Data table 2
ID
Name
rrr
tttt
ppp
77
DatTable 1 contains ID with values but Datatable2 ID has no rows
I want the Datatable2 of row("ID) = Datatable1 of CurrentRow(ID).toString
but its not giving the currect output,.
Expexted output:
Datatable 2 should be like
ID
Name
1
rrr
2
tttt
3
ppp
4
77
Plz help
Dave
(David Wiebelhaus)
April 19, 2021, 4:49pm
2
I dont understand in your example how the ID is matching up in Datatable 2? The names are not the same at all?
If you are just assigning consecutive numbers in the ID column of Datatable 2 then you can do it with a for each statement. For each row in Datatable2, Assign row.item("ID") = CurrentRowIndex+1
CurrentRowIndex is the variable name I made up for the output index of the for each activity
1 Like
MLT
(MLT)
April 19, 2021, 4:51pm
3
Hi @Dave Thanks for reply
I just want the current row of datatable1 should be assigned to the IDs in datatable 2
prasath_S
(prasath S)
April 19, 2021, 4:54pm
4
Hi @MLT
Use for each row and create a variable for index (it is in property of for each row variable name - index)
And inside for each row put assign,
Datatable2.rows(index).item(0) = row(0).tostring
It will assign 1st row is of datatable1 to 1st row id of datatable2 and so on
ppr
(Peter)
April 19, 2021, 4:55pm
5
so give a try on:
for each row - use the index output from this acivity (varname: idx) and loop over dt1
use an assign dt2.Rows(idx)(0) = row(0)
MLT
(MLT)
April 19, 2021, 4:59pm
6
Hi i already tried this one
but it throws error : Assign: There is no row at position 3.
ppr
(Peter)
April 19, 2021, 5:03pm
8
just check if dt2 has the same rowcount as dt1
prasath_S
(prasath S)
April 19, 2021, 5:05pm
9
For this to work both datatables should have same number ot rows…
MLT
(MLT)
April 19, 2021, 5:55pm
10
is there any way if we could do the same, if the row count b/w 2 datables are not same?
prasath_S
(prasath S)
April 19, 2021, 5:59pm
11
Put an if condition inside the for each row and condition will be,
Cint(K) <= Cint(dt1.rows.count.tostring)
And then put the assign inside then of if activity… thanks
MLT
(MLT)
April 19, 2021, 6:03pm
12
thanks @prasath_S but no luck i throws the same error
“message”: “Assign: There is no row at position 1.”,
prasath_S
(prasath S)
April 19, 2021, 6:04pm
13
Can you please share the workflow screenshots please…