How to create two datatable from one table

Hi all,

I have a table in an excel page. In this excel table, more than one table is listed one after the other (the columns of each are the same).

I need to make some opearitons for each row. That is why i used “For each row” activity .But i have to ensure that this loop is done separately for each table.

The thing that distinguishes these tables on excel is customer numbers.

How can I do a separate operation for each table and for each row?

1 Like

In short, it is necessary to create more than one table by grouping the data in one table.

Can you share the excel file? @mazlumkacar

Thanks!

How do you want this data split between two tables? If I’m understanding correctly, you want some of the information from this table to exist in two separate tables you’re planning to iterate over.

Secondly, how do you plan to use the data (abstractly speaking)? You may be able to just iterate over the same table twice and perform different operations each time rather than splitting it.

This is the file.

Sample Excel.xlsx (10.3 KB)

The red column is the column that contain two different customer number. I want to create two table by use it.

@kadiravan_kalidoss

But how can i group a column and create two or more table?

@Anthony_Humphries

What two tables are you trying to create from the Excel sheet? Can you provide an example of what would be in the two datatables?

Here is the two table

1.xlsx (9.9 KB) 2.xlsx (9.2 KB)

@kadiravan_kalidoss
@Anthony_Humphries

@mazlumkacar

Maybe your case allows you to get distinct values for customerNumbers (removing the header value) then iterate over them, filtering the DataTable accordingly.

So I want to ask this very briefly.

How do I find out what different values are in a column?

For example:

I want this table to get me 948 and 946 for the customer number column. In addition, I will need the number of different numbers.

@Anthony_Humphries
@msan
@kadiravan_kalidoss

Assuming you DataTable is name MyDataTable and the DataColumn is named name, you can either have a data table with only one column or a System.Collections.IEnumerable:

DataTable

MyDataTable.DefaultView.ToTable(true, "name")

IEnumerable

From row In MyDataTable.AsEnumerable() Select row.Field(Of String)("name") Distinct

1 Like

Hi @mazlumkacar ,

Please have a look… I have split the datatable based on Şube Kodu id and stored in two different sheets.

Onayli-BAUHAUS_SIPARIS_10022020.xlsx (13.2 KB) splitDatatable.xaml (7.6 KB)

Thanks!

5 Likes

Thanks a lot @kadiravan_kalidoss ! Perfect solution.

I just do not understand why we use strdt variable?

Hi @mazlumkacar,

Just to print the splitted dt in writeline under output panel. For testing purpose only.

u can remove it…!

Thanks!

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