I want to k
now how to get all values against a unique values in excel.
If you see screenshot, there are name and car column.
So I want to get all cars against a unique name. eg. Like Andrew having which cars .
I am attaching the excel. test.xlsx (9.7 KB)
(From d In DtBuild.AsEnumerable
Group d By k=d("Name").toString.Trim Into grp = Group
Let nj = String.Join(",",grp.Select(Function (n) n("Car").toString.Trim))
Let ra = New Object(){k,nj}
Select r = DtOutput.Rows.Add(ra)).CopyToDataTable
I want output not in combine format.
It should be row by row.
Now output is coming like below.
Andrew,“BMW,Tesla,Hyundai”
John,“Merce,Volks”
Elon,“Honda,Maruti”
But I want it separate like
Andrew,“BMW,Tesla,Hyundai”
In general the case looks like a groupBy Scenario / Filter case
A strategy would be adapted depending on what you want to to with. One of many options is to group the rows by name and then package it
e.g. List(Of List(of Datarow)) - outer List: Groups, inner List: the corresponding group members
Assign Activity:
Groups | DataType: List(Of List(of Datarow)) =
(From d In YourDataTableVar.AsEnumerable
Group d By k=d("Name").toString.Trim Into grp = Group
Select g = grp.ToList).toList
A variation of this is to return a list of datatables | 1 DataTable = 1 Group and its members