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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
sow212
Regular Visitor

List of Records to Row - API

Hello,

I'd like to transform "list of records" into row e.g. Media 1, Media 2. See attached image. Any recommendation for the step by step or function? I really appreciate your help, thanks.

Screen Shot 2020-04-10 at 03.49.25.png

1 ACCEPTED SOLUTION
edhans
Super User
Super User

See the following M code, which you need to put in a blank query. 

1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done

 

let
    Source = 0,
    #"Converted to Table" = #table(1, {{Source}}),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each {[A = 1, B = 2],[A = 4, B = 8]}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Expanded Custom1" = Table.ExpandRecordColumn(#"Expanded Custom", "Custom", {"A", "B"}, {"A", "B"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Expanded Custom1", {"Column1"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"

 

Turns this:

2020-04-10 09_26_09-Untitled - Power Query Editor.png

Into this
2020-04-10 09_26_39-Untitled - Power Query Editor.png

Which I then expand and unpivot to get this:

2020-04-10 09_27_26-Untitled - Power Query Editor.png

 

If you need more... How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

See the following M code, which you need to put in a blank query. 

1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done

 

let
    Source = 0,
    #"Converted to Table" = #table(1, {{Source}}),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each {[A = 1, B = 2],[A = 4, B = 8]}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Expanded Custom1" = Table.ExpandRecordColumn(#"Expanded Custom", "Custom", {"A", "B"}, {"A", "B"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Expanded Custom1", {"Column1"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"

 

Turns this:

2020-04-10 09_26_09-Untitled - Power Query Editor.png

Into this
2020-04-10 09_26_39-Untitled - Power Query Editor.png

Which I then expand and unpivot to get this:

2020-04-10 09_27_26-Untitled - Power Query Editor.png

 

If you need more... How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Greg_Deckler
Community Champion
Community Champion

@ImkeF @edhans


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
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors