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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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}}
)
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

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
Back
Top