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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to avoid using Table.Column when there are multiple columns in Power Query

This is my first post, please bare with me, and I am new in this forum, need help

 

I have a source data like as below

 

WillTaylorUK_0-1668151720193.png

 

And the end goal will be like this, 

 

WillTaylorUK_1-1668151770830.png

 

 

Presently I am using the power query with this code

 

let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"Name"}, {{"All", each _, type table [Name=text, Address=text, City=text, State=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.Column([All],"Address")),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each Table.Column([All],"City")),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom.2", each Table.Column([All],"State")),
#"Extracted Values" = Table.TransformColumns(#"Added Custom2", {"Custom", each Text.Combine(List.Transform(_, Text.From), "|"), type text}),
#"Extracted Values1" = Table.TransformColumns(#"Extracted Values", {"Custom.1", each Text.Combine(List.Transform(_, Text.From), "|"), type text}),
#"Extracted Values2" = Table.TransformColumns(#"Extracted Values1", {"Custom.2", each Text.Combine(List.Transform(_, Text.From), "|"), type text}),
#"Removed Columns" = Table.RemoveColumns(#"Extracted Values2",{"All"})
in
#"Removed Columns"

 

In real there are around 30 columns, how can avoid using Table.Column or if I am using Table.Column then how to combine all the columns dynamcially to achieve the above end goal.

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],

#"Grouped Rows" = Table.Group(Source, {"Name"}, List.Trandform(List.Skip(Table.ColumnNames(Source)),(x)=>{x,each Text.Combine(List.Transform(Table.Column(_,x),Text.From),"|")}))

in

#"Grouped Rows"

View solution in original post

1 REPLY 1
wdx223_Daniel
Super User
Super User

let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],

#"Grouped Rows" = Table.Group(Source, {"Name"}, List.Trandform(List.Skip(Table.ColumnNames(Source)),(x)=>{x,each Text.Combine(List.Transform(Table.Column(_,x),Text.From),"|")}))

in

#"Grouped Rows"

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.