In Power Query, how do you Group a table by a column and then concatenate instead of a SUM for one of the columns?

alex1alex

Board Regular
Joined
Sep 12, 2014
Messages
57
Hello,

In the end I'm trying to get something like this.
start with table
A B C
1 a 1
1 b 2
2 c 3
3 d 4
end with table
A CatOfB
1 a:b
2 c
3 d
(where CatofB is a concatination of all B column fields that match column A)

using this as a start:
aTable = #table({"A","B","C"},{{1,"a",1},{1,"b",2},{2,"c",3},{3,"d",4}}),

i can do a sum of C:
aGroupRowsSum = Table.Group(
aTable,
{"A"},
{{" Sum of C", each List.Sum([C]), type number}}
),

where aGroupRowsSum =
A SumOfC
1 3
2 3
3 4

But i can't figure out how to do the concatenate of B.
This seems close but no cigar:
fCombine = Combiner.CombineTextByDelimiter(":"),
aGroupRowsCat = Table.Group(
aTable,
{"A"},
{{"CatOfB", fCombine (each ([C])), type text}}
)



Any suggestions?

Thanks,
Alex
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

alex1alex

Board Regular
Joined
Sep 12, 2014
Messages
57
Arg, I didn't understand how the each works.

This works great, bold is what I changed :

aGroupRowsCat = Table.Group(
aTable,
{"A"},
{{"CatOfB", each fCombine([C]), type text}}
)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,593
Messages
5,838,257
Members
430,536
Latest member
Manoj Gaidhankar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top