aqiff
(Aqiff)
September 30, 2021, 1:16pm
1
Assuming below is the column that I filtered (dt2). I want to add this filtered column to another data table
Amount
1896.923289
1102414.908174
714.178
1851.649981
10103.52375
22300.8302
Another table value (dt1) is as below
Destination,Rate,Mins
China,0.017,110286.25
India,0.23,4850043.58333333
Korea,0.015,47611.8666666666
MALAYSIA,0.2,9258.25
Singapore,0.009,1122613.75
Yemen,0.21,104698.733333333
I tried to use Add data column, but it gives me error “Add Data Column: Column ‘Amount’ already belongs to another DataTable.”. The properties as below;
Column: dt2.Columns(“Amount”)
DataTable: dt1
Charbel1
(Charbel)
September 30, 2021, 1:22pm
2
As mentioned by @supermanPunch
a datacolumn from one datatable cannot be used for an direct addition to another datatable.
And this is the reason why the error is shown.
As an alternate you can do (Create Datacol, and transfer settings from other datacolumn)
Variables
[grafik]
Flow:
[grafik]
[grafik]
it also depends on your scenario details. We get also compact flows we clone datatable and a further datacolumn structre modification
You can refer to this solution.
Hi
If this is in a datatable named dt2 then the below steps will help you resolve this
—use a assign activity and mention line this
dt_col = dt2.Columns(0)
Where dt_col is a variable of type System.Data.DataColumn defined in variable panel
—now use ADD DATACOLUMN activity and pass the above variable to DataCol property and in datatable property mention as dt1
Cheers @aqiff
aqiff
(Aqiff)
September 30, 2021, 3:26pm
4
. Nope still give me an error “Amount” belongs to another datatable.
aqiff
(Aqiff)
September 30, 2021, 3:26pm
5
i’ve tried this, but it gives me a column of data table with empty values
Charbel1
(Charbel)
October 1, 2021, 5:08am
6
Can you share your workflow or screenshots of activities + properties please?
Srini84
(Srinivas Kadamati)
October 2, 2021, 7:46am
7
@aqiff
Can you share the excel files if you have and also check the output you required
Thanks
Before to this step use a assign activity and give a try by changing the columnname
dt2.Columns(0).ColumnName = “Amounts”
We are just trying add like Amounts instead of amount
And then use this in a assign
dt_col = dt2.Columns(0)
Then continue further with the above mentioned steps
Cheers @aqiff
aqiff
(Aqiff)
October 3, 2021, 1:24pm
9
@Palaniyappan @Charbel1 @Srini84 , Attached is the workflow. Sorry for the late reply, inside the workflow, Method 1 is by @Charbel1 , Method 2 is by @Palaniyappan . Both has its own error. Do try it out
SortRate2.xaml (14.9 KB)
Charbel1
(Charbel)
October 3, 2021, 1:39pm
10
I’m not getting any error from my side for Method 1. I runned your workflow on my machine.
Can you please send the error that you are getting?
aqiff
(Aqiff)
October 3, 2021, 1:50pm
11
If you in debug mode, The column for “Amount” is empty
Charbel1
(Charbel)
October 3, 2021, 1:56pm
12
Yeah, you’re right just checked it…
Did you try a simple for each row maybe?
aqiff
(Aqiff)
October 3, 2021, 1:59pm
13
I’ve used this, but I thought, maybe there is much more easier and convenient way to add new data column.
Charbel1
(Charbel)
October 3, 2021, 2:09pm
14
After some search, the reason we can’t do this is that the reference of the column is tight to its Datatable which means that if you add this column to another Datatable, you will mess the references which can blow your program.
That’s why the only method would be to copy the data one by one (For Each Row).
But the first answer is still valid to add the column name and the type (but without data, unfortunately…)
Best,
Charbel
Palaniyappan:
Before to this step use a assign activity and give a try by changing the columnname
dt2.Columns(0).ColumnName = “Amounts”
We are just trying add like Amounts instead of amount
And then use this in a assign
dt_col = dt2.Columns(0)
Then continue further with the above mentioned steps
Hi
This steps should be working
Pls upgrade the UiPath.System.Activities package and UiPath.UIAutomation package and give a try
Cheers @aqiff
aqiff
(Aqiff)
October 3, 2021, 2:22pm
16
I have upgraded and nope, its not working