Hello,
I have a datatable composed of 4 columns, as in the image:
I need to group the rows that have the same “Number” AND “Name” and “Code” column values as follows:
The result in the example should return me 8 datatables.
Any idea to achieve this?
Thanks!
Hi
Have a view on this thread for some idea
I need to split datatable into two datatables based on Group by and another column values.
From the Source Datatable, I need to move records based on Group by columns “Col 1” and “Col 2”. In addition, if the values in the “Col 3” contains “I” & “A”, then the set of records should be moved to new datatable (DT1). And rest of the Source Datatable should be moved to another new datatable (DT2). Please help me to solve this.
What I have:
Source Datatable:
[image]
What I need:
In a New Datatabl…
Cheers @andreus91
Gokul001
(Gokul Balaji)
March 9, 2022, 1:54pm
4
Hi @andreus91
Have a look on the thread
@jamnanin
I will suggest you one more way try like this.
Let us take your excel stored in a datatable dta
First group the datatable based on ID by using below Query and assign it to dt1
dt1=(From p In dta.Select()
Group p by ID=p.Item(“ID”).ToString Into Group
Select Group(0)).ToArray.CopyToDataTable()
Now take only two columns by using below query
dt1=dt1.DefaultView.ToTable(False,“ID”,“Name”)
Now Add one datacolumn to dt1 by using add datacolumn activity and give name Amount to that c…
Regards
Gokul
ppr
(Peter Preuss)
March 9, 2022, 1:56pm
5
assign Activity
LHS: TableList | List(of DataTable)
RHS
(From d in YourDataTableVar.AsEnumerable
Group d by k1=d("Name").toString, k2=d("Number").toString, k3=d("Code").toString into grp=Group
Select t=grp.CopyToDataTAble).toList
Also Have a look here:
2 Likes
Thanks to all, i’m signing your solution as the correct one!
system
(system)
Closed
March 12, 2022, 2:08pm
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.