Forum Discussion
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.
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 Donelet 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:
Into this
Which I then expand and unpivot to get this:
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
2 Replies
- edhansCommunity Champion
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 Donelet 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:
Into this
Which I then expand and unpivot to get this:
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 - Greg_DecklerCommunity Champion