How to divide the datatable based on column index and column name?

This is my main data table. Now, I want to divide into 3 data tables. And store to a 3 different sheet.

1 Like

Hi @ganesh_rajan

You can do this by following the below steps.

  1. So first do a read range and get your main datatable populated.
  2. Use three Build data table activities to build the structue of the three datatables you need
  3. Use aFor each row activity to loop through the main datatable
  4. Within the loop use three Add data row activities to separately add the data to each table.
    So in each add data row activity, use the Array Row property and provide the columns you need to enter from the main DT to your new DT. The array should look like below

{row("ColumnName").Tostring, row("ColumnName").ToString}

Like wise you can keep on adding the columns you need to insert by separating by a comma.

Do the same for all three add data row activities and point them to each datatable you created.

This will get all three data table populated from your main datatable without a problem :slight_smile:

Let me know how it goes…

3 Likes

Yep it is possible.IF columns Are fixed like
1.use read range activity mention Range property Like “A1:E10000”(Required Columns) and store it in data table,


2.use write range activity to write the data table in one Excel
3.again do the same reaming ranges
OR
store the ranges in a list or array for each in read activity pass the value in range property same in excel

You could read the entire table as one then select each sub-table using an expression, assuming all column names are unique. Use in an assign activity:

NewDataTable = SourceDataTable.Select().CopyToDataTable().DefaultView.ToTable(False, “Column1”, “Column2”)

Example attached.

Main.xaml (5.2 KB)

2 Likes

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