Do you want Group by Month ? You can use Sum to summarize groups:
Dim query = From row In dt Group row By Month = row.Field(Of Int32)("Month") Into MonthGroup = Group Select New With { Key Month, .Sales = MonthGroup.Sum(Function(r) r.Field(Of Int32)("Sales")), .Leads = MonthGroup.Sum(Function(r) r.Field(Of Int32)("Leads")), .Gross = MonthGroup.Sum(Function(r) r.Field(Of Int32)("Gross")) } For Each x In query Console.WriteLine("Month:{0} {1} {2} {3}", x.Month, x.Sales, x.Leads, x.Gross) Next
This is a mix of Linq query- and method-syntax.
Tim schmelter
source share