# Group by column and join the other columns

HI

I have the following table

|RFC | 1 | 2 | 3 | 4 | Total|
|E21 | 1.2 | 3.5 | | | 4.7|
|A98 | | | 2.4 | | 2.4|
|T56 | | 2.1 | | 2.7 | 4.8|
|E21 | | | | 1.3 | 1.3|

and i need group by RFC but the other columns have to be joined, the output table has to be like this

|RFC | 1 | 2 | 3 | 4 | Total|
|E21 | 1.2 | 3.5 | | 1.3 | 6|
|A98 | | | 2.4 | | 2.4|
|T56 | | 2.1 | | 2.7 | 4.8|

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}

Have you tried Join DataTable activity?

Thanks,
Ashok

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