Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
coathangers
Frequent Visitor

Group by with Text.Combine+List.Transform

Hi,

 

I am trying to concatenate rows using Tables.Group and Text.Combine+List.Transform. I want to sort the order so that the rows are concatenated alphabetically (Power Bi is doing this reverse alphabetical order).

 

Example data:

ConsoleGame
Nintendo     Animal Crossing
NintendoMario
NintendoZelda
PCCOD
PCGTA
PS4Burnout
PS4COD
PS4Darksouls
PS4GTA
XboxBurnout
XboxCOD
XboxDarksouls
XboxGTA

 

When I use Text.Combine+List.Transform it is returning this:

 

ConsoleGames
XboxGTA | Darksouls | COD | Burnout
PS4GTA | Darksouls | COD | Burnout
Nintendo     Zelda | Mario | Animal Crossing
PCGTA | COD

 

I want the data to be concatenated alphabetically:

 

ConsoleGames
XboxBurnout | COD | Darksouls | GTA
PS4Burnout | COD | Darksouls | GTA
Nintendo     Animal Crossing | Mario | Zelda
PCCOD | GTA

 

I am using this code (adapted for the above example):

 

= Table.Group(#"Previous Step", {"Console"}, {{"Games", each Text.Combine(List.Transform([Game], Text.From), " | "), type text}})

 

I have tried using an order, but it has no effect:

 

= Table.Group(#"Previous Step", {"Console"}, {{"Games", each Text.Combine(List.Transform([Game], Text.From), " | "), type text, Order.Ascending}})

 

The sort order of the query from previous steps has no effect on the Table.Group query.

 

Any suggestions please? 

 

Many thanks

Colin

 

[Edited to include missing { , thanks @ChrisMendoza ]

1 ACCEPTED SOLUTION

I found the solution here:

 

PowerQuery order of words in Text.Combine - Stack Overflow

 

We first need to override the Power BI internal sort using Table.Buffer and then sort by Console ascending and Game ascending.

 

The Text.Combine has no means of sorting, this Table.Buffer needs to be a previous step in the query.

View solution in original post

4 REPLIES 4
ChrisMendoza
Resident Rockstar
Resident Rockstar

@coathangers - Only difference I see is an opening " { ".
image.png

= Table.Group(#"Changed Type", {"Console"}, {{"Games", each Text.Combine(List.Transform([Game], Text.From), " | "), type text, Order.Ascending}})

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



I found the solution here:

 

PowerQuery order of words in Text.Combine - Stack Overflow

 

We first need to override the Power BI internal sort using Table.Buffer and then sort by Console ascending and Game ascending.

 

The Text.Combine has no means of sorting, this Table.Buffer needs to be a previous step in the query.

Anonymous
Not applicable

You can also use this:

= Table.Group(#"Changed Type", {"Console"}, {{"Games", each Text.Combine(List.Sort([Game]), " | " ), type text}})

 

Thanks for the reply. 

 

Sorry that code was typed rather than copied from the source and I forgot the {. The source data I have is sensitive so can't copy directly. 

 

Even with that opening { (which is how the code in my query actually is) the Order.Ascending has no effect, the concatentation is in reverse alphabetical order for some reason. Did you try Order.Descending in your query, and did that have any effect?

 

Many thanks,

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors