Can anyone help me with the approach or link query for adding the column with its data to another data table?
Thanks,
Shreyash
Can anyone help me with the approach or link query for adding the column with its data to another data table?
Thanks,
Shreyash
you can use invoke code activity
can you share what was your input and expected output
Hello @shreyash_shirbhate
Use a âBuild Data Tableâ activity to create an empty destination DataTable (e.g., dtDestination) with the same structure as the source DataTable (e.g., dtSource).
Use a âFor Each Rowâ activity to iterate through each row in dtSource:
Inside the loop, use the âAdd Data Rowâ activity:
After the loop, dtDestination will contain the data from dtSource, and you can use it as needed.
Optionally, you can use a âWrite Rangeâ activity to write the destination DataTable to an Excel file or another destination.
Thanks & Cheers!!!
if you want to fill a new column based on another column then join also can do the job
cheers
depending on the details:
Hi Shiva,
I have a 2 data table lets say dt1 and dt2.
I want to add the column âABCâ from dt1 to dt2 at last.
I tried using add data column using data column object but it is just copying the heading and not the data.
I followed this post by @ppr . But it is not copying my column data.
@Kartheek_Battu, I donât want to do it with the for each loop.
I am finding out for linq/invoke code or any other easy way.
just be more clear in the details:
please lets avoid ping-pong as sample data was asked, but not shared
Hi @ppr,
I have a 2 data table lets say dt1 and dt2.
I want to add the column âABCâ along with the data from dt1 to dt2 at last.
unfortunately no samples was shared
Have a look if the side-by-side merge is matching your case
Hi @ppr,
Here is the sample data.
I want it something like this. Itâs simple lets take Column D from dt1 and add Same Column in dt2 along with itâs data.
Hope itâs clear now.
looks like a side-by-side merge
Starter help as shared above
Help Customization: Add dt1 Last col value to dt2 as Last Col Value, where over all ColumnStructure was defined on a dtResult
Project Compatibility: Windows
(From i In Enumerable.Range(0, {dt1.Rows.Count, dt2.Rows.Count}.Max())
Let ra1 = If(i < dt1.Rows.Count, dt1.Rows(i).ItemArray, dt1.NewRow.ItemArray)
Let ra2 = If(i < dt2.Rows.Count, dt2.Rows(i).ItemArray, dt2.NewRow.ItemArray)
Let ra = ra2.Concat(ra1.TakeLast(1)).ToArray
Select r= dtResult.Rows.Add(ra)).CopyToDataTable
My code is in windowâs legacy.
(From i In Enumerable.Range(0, {dt1.Rows.Count, dt2.Rows.Count}.Max())
Let ra1 = If(i < dt1.Rows.Count, dt1.Rows(i).ItemArray, dt1.NewRow.ItemArray)
Let ra2 = If(i < dt2.Rows.Count, dt2.Rows(i).ItemArray, dt2.NewRow.ItemArray)
Let ra = ra2.Concat(ra1.Skip(ra1.Length-1).Take(1)).ToArray
Select r= dtResult.Rows.Add(ra)).CopyToDataTable