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
Anonymous
Not applicable

Power Query: How merge row results and separate by comma

Hi,

 

I have a table I'm bringing in to Power BI.  I would like to merge several rows together and have the results separated by a comma.  The issue is, sometimes there are blanks for some of the fields and I do not want commas included if there are blanks in these fields.

 

Here is an example of my data/table in Power BI:

 

Name         Engine       Cylinders       Turbo       Boost       Exhaust

Andy          400            8                    Turbo       5psi         Duel

Bob            427                                                  10psi       Duel

Dan            255           6                                                    Single

 

I would like to merge the results together in fields Cylinder, Turbo, Boost and Exhaust so the newly created column would have the following results (highlighted in Red):

 

Name         Engine       Cylinders       Turbo       Boost       Exhaust       New Column      

Andy          400            8                    Turbo       5psi         Duel             8, Turbo, 5psi, Duel

Bob            427                                                  10psi       Duel             10psi, Duel

Dan            255           6                                                    Single           6, Single

 

I know Power Query has the 'Group By' trandformation but I don't believe that is what I need in this situation.  I'm not sure what the custom column would need to be in order to accomplish this merge tat I'm trying to do.

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous ,

 

Add a new column with the following code:

 

[Cylinders] & (if [Cylinders] = ""  then "" else "," )
& [Turbo]
 &

(if [Turbo] = "" then "" else "," ) & [Boost]
& 
(if [Boost] = "" then "" else "," ) & [Exhaust]

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Anonymous ,

 

Add a new column with the following code:

 

[Cylinders] & (if [Cylinders] = ""  then "" else "," )
& [Turbo]
 &

(if [Turbo] = "" then "" else "," ) & [Boost]
& 
(if [Boost] = "" then "" else "," ) & [Exhaust]

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Greg_Deckler
Community Champion
Community Champion

@Anonymous You could use the "&" concatenation operator like this:

[Cylinders] & "," & [Turbo] & "," & [Boost] & "," & [Exhaust]



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.