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

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

Reply
EaglesTony
Post Prodigy
Post Prodigy

How do i combine multiple columns based on a group by of another column ?

Hi,

 

  I have the following data:

 

Ruleid               RoleName              FullName

123                   Teacher                   John Doe

123                   Principal                 Jane Doe

123                   Assistant                Frank Drain

123                   Counsler                Mary Dodge

456                   Teacher                  Mark Adams

 

I need it to be something like this

Ruleid             AllAlike

123                 Teacher:John Doe, Principal:Jane Doe, Assistant:Frank Drain, Counsler:Mary Dodge

456                 Teacher:Mark Adams

 

Thanks

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

NewStep=Table.Group(YourSource,"Ruleid",{"AllAlike",each Text.Combine(Table.ToList(_,each Text.Combine(List.Skip(_),":")),",")})

View solution in original post

3 REPLIES 3
dufoq3
Super User
Super User

Hi @EaglesTony, another solution:

dufoq3_0-1758726083813.png

 

Add as a new step:

= Table.Group(Source, {"Ruleid"}, {{"AllAlike", each Text.Combine(Table.CombineColumns(_,{"RoleName", "FullName"},Combiner.CombineTextByDelimiter(":", QuoteStyle.None),"Merged")[Merged], ", "), type text}})

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

wdx223_Daniel
Super User
Super User

NewStep=Table.Group(YourSource,"Ruleid",{"AllAlike",each Text.Combine(Table.ToList(_,each Text.Combine(List.Skip(_),":")),",")})

m_dekorte
Super User
Super User

Hi @EaglesTony 


Here are the steps to achieve that. Hold down CTRL and select the RoleName and FullName columns, go to the Transform tab use Merge Columns to combine them into a single AllAlike column.

Now you can use the Group By option (can also be found on the Transform tab), setting RuleID as the key column, and setting an aggregation for the AllAlike column - any aggregation will work, since you’ll be adjusting the formula manually in the formula bar afterwards, I've set it to Sum.

m_dekorte_1-1758036229708.png


In the formula bar look for the list that looks like this:

{{"AllAlike", each List.Sum([AllAlike]), type text}}


Replace the List.Sum function with Text.Combine. Then, before the closing parenthesis, add a separator (for example, ", "). The updated code will look like this:

{{"AllAlike", each Text.Combine([AllAlike], ", "), type text}}


All done!

m_dekorte_2-1758036627941.png 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyVtJRCklNTM5ILQKyvPIz8hRc8lOVYnVgkgFFmXnJmQWJOSDpxLxUNGnH4uLM4pLEvBIg260oMS9bwaUoMTMPSYVzfmlecQ7YeN/Eokqg/pR0iAkmpmYotgOlsxUcUxJzi5ViYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ruleid = _t, RoleName = _t, FullName = _t]),
    #"Merged Columns" = Table.CombineColumns(Source,{"RoleName", "FullName"},Combiner.CombineTextByDelimiter(": ", QuoteStyle.None),"AllAlike"),
    #"Grouped Rows" = Table.Group(#"Merged Columns", {"Ruleid"}, {{"AllAlike", each Text.Combine([AllAlike], ", "), type text}})
in
    #"Grouped Rows"


I hope this is helpful.

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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 Kudoed Authors