I have the sum of the totals, but I can’t join columns 1 to 5
This is how I’m grouping and adding the totals, but i can’t join the other column
(From row In dtInput.AsEnumerable
Group row By sc = row(“RFC”).ToString()
Into grp = Group
Let total = grp.Sum(Function (x) Convert.ToDouble(x(“Total”).ToString().Trim()))
Let result = New Object() {grp(0)(“RFC”),total}
Select dtOutput.Rows.Add(result)).CopyToDataTable
WE would construct the full itemarray e.g By taking each column first Not null value
UPD1 -
extended to full approach
(From d In dtData.AsEnumerable
Group d By k = d("RFC").ToString().Trim Into grp = Group
Let total = grp.Sum(Function (x) Convert.ToDouble(x("Total").ToString().Trim()))
Let arrCols = {"1","2","3","4"}
Let ram = arrCols.Select(Function (c) grp.select(Function (g) g(c)).Where(Function (v) Not String.IsnullorEmpty( v.ToString().Trim())).FirstOrDefault()).toArray
Let ra = ram.Prepend(k).Append(total).toArray
Select r = dtResult.Rows.Add(ra)).CopyToDataTable
we would recommend the following adaptions:
externalize and dynamize the arrCols
clear the need of handling e.g more then 2 rows per group