Seperating Datatables

Hello All!

I want to seperate datatables.
image

I want to see Company is A ->Datatable has to contains James&Erica,
Company is B-> Datatable has contains Thomas, Eric, Jessica.

Test.xlsx (8.5 KB)

Which assign or for each can i used?
(Dynamic Company) Maybe 1 maybe more

Hi,

Can you try the following sample?

dict = dt.AsEnumerable.GroupBy(Function(r) r("Company").ToString).ToDictionary(Function(g) g.Key, Function(g) g.CopyToDataTable())

Sample
Sample20240627-3.zip (9.2 KB)

Regards,

Hi @Betul_Dundar

=> Use Assign activity to assign counter:

Count = 1

=> Read Range Workbook
Output → InputDt

=> Use below code in Invoke Code:

' Ensure strict type conversion
Dim groupedData As Dictionary(Of String, DataTable) = InputDt.AsEnumerable() _
    .GroupBy(Function(row) (row("Company").ToString)) _
    .ToDictionary(Function(g) (g.Key), Function(g) g.CopyToDataTable())

' Initialize the output dictionary
GroupedDataTables = New Dictionary(Of String, DataTable)()

' Add each group to the dictionary
For Each kvp In groupedData
    GroupedDataTables.Add(kvp.Key, kvp.Value)
Next

Invoked Arguments:

=> Use For Each loop to iterate through GroupedDataTables

For Each currentKeyValuePairOfTextAndDataTable in GroupedDataTables
    Write Range Workbook -> pass datatable as currentKeyValuePairOfTextAndDataTable
    Assign -> Count = Count + 1
End For Each

FLOW:

VARIABLE DATATYPES:

XAML:
Sequence27.xaml (12.1 KB)

OUTPUT:
Test (2).xlsx (10.1 KB)

Hope it helps!!

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