cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Rows to Columns

Hi,

 

i've been looking for solution for some days and not yet succeeded. Task is simple, or atleast it should be:

 

This is what i have:

 

place_IDtag
1X
1Y
2X
2Y
1900X
1900

Y

 

This is what i want:

 

place_IDtag XTag Y
1XY
2XY
1900XY

 

I need this to be done at Query editor.  Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Rows to Columns

@problematic111

 

Give this a try

File attached as well

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"place_ID", Int64.Type}, {"tag", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"place_ID"}, {{"AllRows", each _, type table}}),
    #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Custom.1", each Table.Transpose(Table.SelectColumns([AllRows],"tag"))),
    #"Expanded Custom.1" = Table.ExpandTableColumn(#"Added Custom1", "Custom.1", {"Column1", "Column2"}, {"Column1", "Column2"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom.1",{"AllRows"})
in
    #"Removed Columns"
Try my new Power BI game Cross the River

View solution in original post

2 REPLIES 2
Highlighted
Super User III
Super User III

Re: Rows to Columns

@problematic111

 

Give this a try

File attached as well

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"place_ID", Int64.Type}, {"tag", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"place_ID"}, {{"AllRows", each _, type table}}),
    #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Custom.1", each Table.Transpose(Table.SelectColumns([AllRows],"tag"))),
    #"Expanded Custom.1" = Table.ExpandTableColumn(#"Added Custom1", "Custom.1", {"Column1", "Column2"}, {"Column1", "Column2"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom.1",{"AllRows"})
in
    #"Removed Columns"
Try my new Power BI game Cross the River

View solution in original post

Highlighted
New Member

Re: Rows to Columns

Works like a charm! 5/5

Helpful resources

Announcements
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Top Solution Authors