There are 6 billing document in this sheet. Sometimes, there are 2 or 3 products in one billing documents
If there is only one product in one billing document, I need to move all these rows(including headers) to a new sheet(name row1)
If there are 2 products in one billing document, I need to move all these rows(including headers) to a new sheet(name row2)
If there are 3 products in one billing document, I need to move all these rows(including headers) to a new sheet(name row3)
PS: Usually there is only one product in one billing document in this sheet, but sometimes 2-3 products in one billing cases occur. So I need to consider all scenarios
I don’t need to put every single billing document in a new sheet
Only the ones with one product in one billing document in row1 together
and the ones with two products in one billing document in row2 together
and the ones with three products in one billing document in row3 together
Can you help take a look how to adjust the coding to meet the request?
we can seperate the into groups based on Billing Document
then we want to group again based on the group Member account
This we can achieve with a second grouping
From this aggregated groups we return the segment tables
LINQ:
(From d In dtData.AsEnumerable
Group d By k=d("Billing Document").toString.Trim Into grp=Group
Group grp By c=grp.Count Into grp2=Group
Let t = grp2.SelectMany(Function (x) x).CopyToDataTable
Order By grp2.First().Count
Select tbl=t).ToList