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

Merging an unknown number of columns

Hello,

I am using Jira CSV data that I query directly from the Web.

In this data, comments are added as new columns depending on the number of comments.

So if a record has 2 comments, there will be 2 columns accordingly: comments.1 and comments.2

Etc, etc.

I would like to concactenate these columns (only when not empty) for my entire dataset without knowing beforehand the number of columns (as this can vary).

Is there an easy way to do this ?

Thanks

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Please see the attached file with a solution

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

View solution in original post

2 REPLIES 2
Jimmy801
Community Champion
Community Champion

Hello @Anonymous ,

 

this would be a solution thats its really dynamic

let
	Source = #table
	(
		{"Comment","xy","zz","test"},
		{
			{"abc","f","500","5"},	{"a","c","200","3"},	{"o","d","",""}
		}
	),
    ChangeType = Table.TransformColumnTypes(Source,{{"zz", Int64.Type}}),
	ToRows= Table.ToRows
	(
		ChangeType
	),
	Transform = List.Transform
	(
		ToRows,
		(transform)=> Text.Combine(List.Select( List.Transform(transform, (transform1)=> Text.From(transform1)), each _ <> ""), ", ")
	),
	Combine = Table.FromColumns
	(
		Table.ToColumns(ChangeType)&{Transform},
		Table.ColumnNames(ChangeType)&{"Concatenating"}
	)
in
	Combine

 

Copy paste this code to the advanced editor to see how the solution works. If this solution fits your need, copy and past a part of it and implement it in your query, or I could create a custom function what makes it easier to apply if you are not used that much to power query.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Please see the attached file with a solution

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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