Forum Discussion
Expand list with records to columns
- Anonymous3 years ago
Hi a_hauser ,
Please refer to the following steps:
let Source = [ID={"ID_1","ID_1","ID_2","ID_3","ID_3","ID_3"},ColumnName={[a=11],[a=22],[a=33],[a=44],[a=55],[a=66]}], #"Converted to Table" = Record.ToTable(Source), #"Pivoted Column" = Table.Pivot(#"Converted to Table", List.Distinct(#"Converted to Table"[Name]), "Name", "Value"), #"Expanded ID" = Table.ExpandListColumn(#"Pivoted Column", "ID"), #"Expanded ColumnName" = Table.ExpandListColumn(#"Expanded ID", "ColumnName"), #"Grouped Rows" = Table.Group(#"Expanded ColumnName", {"ID"}, {{"data", each Table.Transpose(Table.SelectColumns(_,{"ColumnName"}))}}), #"Expanded data" = Table.ExpandTableColumn(#"Grouped Rows", "data", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12"}, {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12"}) in #"Expanded data"Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi a_hauser ,
Please refer to the following steps:
let
Source = [ID={"ID_1","ID_1","ID_2","ID_3","ID_3","ID_3"},ColumnName={[a=11],[a=22],[a=33],[a=44],[a=55],[a=66]}],
#"Converted to Table" = Record.ToTable(Source),
#"Pivoted Column" = Table.Pivot(#"Converted to Table", List.Distinct(#"Converted to Table"[Name]), "Name", "Value"),
#"Expanded ID" = Table.ExpandListColumn(#"Pivoted Column", "ID"),
#"Expanded ColumnName" = Table.ExpandListColumn(#"Expanded ID", "ColumnName"),
#"Grouped Rows" = Table.Group(#"Expanded ColumnName", {"ID"}, {{"data", each Table.Transpose(Table.SelectColumns(_,{"ColumnName"}))}}),
#"Expanded data" = Table.ExpandTableColumn(#"Grouped Rows", "data", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12"}, {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10", "Column11", "Column12"})
in
#"Expanded data"
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum