Merge two tables, equalizing number of rows

Hí,

I am building a workflow to extract data from a website. The robot is entering a value A, for instance 1234. (This value is saved in a variable)

The website is searched, and the data extracted and saved to a data table B.

What I need a good solution for is to add value A in a new column in front of each row of the extracted data.

Datatable B may have different number of rows.

So DT B can look like this:

Some data here and here and here
Some data here and here and here
Some data here and here and here
Some data here and here and here

Then I wish to add in the value in variable A (for instance 1234)

The result should be like this:

1234 Some data here and here and here
1234 Some data here and here and here
1234 Some data here and here and here
1234 Some data here and here and here

One way to do do this is to write Var A to a DT A and merge that with DT B. But the merged DT will only have one row for Var A (1234)

How can I get as many rows in DTA as it is in DTB, so the merged DT has an equal number of rows?

Hey @Evert_Randers ,
As per my understanding from your explaination You can

  1. Put a for each row in Data table activity for DTB.
    2.You can create one more data Table lets Say DTC
    3.Then inside the for each row acitivity use “Add data row” Activity and pass the A value and Currentrow(“ColumnNameOfDTB”)

  1. So that you will get your required output in DTC.
    Is this what you want?

Regards,

@Evert_Randers Assign DTB=DTA.AsEnumerable().CopyToDataTable(). Then use Add Data Column activity with following properties. Setting default value will prepopulate newly added column with values.

Hi @Evert_Randers ,

Refer this workflow to get an idea on your usecase:
Evert.xaml (11.4 KB)

Hello,

  • Use Add Data Column first to the extracted DataTable
  • Loop the extracted datatable
  • Use Add Data Row Activity and add those value

Br.

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