lets assume following sample data:
preparing the target datatable dtTarget with a build datatable
we can do:
dtTarget =
(From d In dtData.AsEnumerable
Group d By k=d("Location").toString.Trim Into grp=Group
Let s = grp.Sum(Function (s) CInt( s(0).toString.Trim))
Let a = grp.Average(Function (a) CInt(a(1).toString.Trim))
Let ra = New Object(){k,s,a}
Select r=dtResult.Rows.Add(ra)).CopyToDataTable
AVG for A = (100+250)/2
or more precise on the Avg
(From d In dtData.AsEnumerable
Group d By k=d("Location").toString.Trim Into grp=Group
Let tp = grp.Sum(Function (t) CInt(t(0).toString.Trim) * CInt(t(1).toString.Trim ))
Let s = grp.Sum(Function (s) CInt( s(0).toString.Trim))
Let a =tp/s
Let ra = New Object(){k,s,a}
Select r=dtResult.Rows.Add(ra)).CopyToDataTable
Avg for A = (2*100+3*250) / (2+3)
Also have a look here for LINQ and GroupBy