Multiple Rows insert using single "Add Data Row" activity

Hi,

I am having two for each to iterate through two different data table. If the data row between two datatable matches I want to create a new datatable with matching rows from the two datatable.

eg: In datatable 1 i will be having 5 columns so, column 1 and column 2 data, matches the column 1 and column 2 data of the datatable 2(it has 7 columns) I want to combine the two datatable rows and using “Add Row” activity I want to create as new datatable.

@Palaniyappan

1 Like

@monish06 , please go through this post: Story line of Join Data Table
you can use inner join

Regards
Shanmukh

2 Likes

Actually in my case, my datatable 2 has 1000 of records with duplicate name, I have already tried the Join approach. Thats why I am comparing with 2nd datable and fetching the row with the first occurrence.

@monish06
If join not working then Try with Linq
To get matched result:
Datatable Out_Matched_Data = In_DataTable1.AsEnumerable().Where(function(row) In_DataTable2.AsEnumerable().Select(function® r.Field(Of String)( VoteNo.ToString)).Any(function(x) x = row.Field(Of String)(VoteNo.ToString))).CopyToDataTable()

1 Like

@monish06 It would be helpful if you Show us How the Input Files appear and the Expected Output that you want using Screenshots. Sample example Data is fine as well.

1 Like

Am not getting the expected output.

Actually I am having 2 datatables, each datatable has different column counts, so once particular column in each datable matches I want to get the matching row along with both the data tables column and create a new datatable. I have attached the xaml file.

ReferenceTableMatch_TV.xaml (17.9 KB)

@monish06 I needed the Input Excel Files and the Expected Output Excel File :sweat_smile:, If the Data is Only Available in Datatables , You can use Write range to put it in an Excel File and provide it. We can provide Solution Faster if you provide Inputs, The Operation needed to be performed and the Output Expected :sweat_smile:

1 Like

sorry bro excel cannot be shared bro due the company’s security concerns, I just want to know if there is two datarow am getting from 2 for each row activity, how can i append these two row say(row and row1) as single datarow and push it into datatable I have built.

1 Like

Fine
I hope there are two datatables been iterated with two FOR EACH ROW activity one within another

So if the first for each row activity is with variable row mention the second for each row activity as row1

Now inside the second for each row activity you would have done a comparison and if it matches it will go to then or else part based on the condition
In them you would have used ADD DATAROW activity with datatable name as Finaldt
And in ArrayRow mention as {row(“yourcolumnname”),row(“yourcolumnname”),row(“yourcolumnname”),row1(“columnname”),row1(“columnname”)…,}

Here we have mentioned row and row1 to differentiate the datatable and their rows

Cheers @monish06

1 Like

What if I want to row all the columns from first for each and all the columns from second for each? The reason is in my second for each row1 it has more than 15 columns, I want all the 15 columns + first for each row’s 5 columns.

1 Like

Fine
Did we try mentioning like this in the ArrayRow property of the add Datarow activity
row1.ItemArray.Concat(row.ItemArray)
Or
row1.ItemArray.Union(row.ItemArray)

Cheers @monish06

1 Like

Am getting error for both the queries.

1 Like

Mention like this Buddy
(row1.ItemArray.Concat(row.ItemArray)).ToArray

Cheers @monish06

3 Likes

Perfect Thanks bro

1 Like

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