Forum Discussion
GDE
6 years agoRegular Visitor
Transpose a List in Power Query
How do I Transpose a List like: {1, 2, 3} into another List like: {{1}, {2}, {3}} in Power Query? Thanks in advance!
- 6 years ago
Table.ToRows(Table.FromList(List))
- 3 years ago
= List.Zip( { your_list } )
example: List.Zip( { {1, 2, 3} } ) = { {1}, {2}, {3} }
GDE
3 years agoRegular Visitor
IMHO, this is the best one, I've seen so far. 🙂
mapelli
3 years agoFrequent Visitor
Yeah... this is the equivalent to the transpose for lists.
I use it often with Table.RenameColumns; example:
let
Source = Table.FromRecords({
[name_1= "John", address_2= "CA", id_3= "[email protected]"],
[name_1= "Juan", address_2= "MX", id_3= "[email protected]"],
[name_1= "João", address_2= "BR", id_3= "[email protected]"]
}),
TransposedLists = List.Zip( { /* current column names: */ Table.ColumnNames(Source),
/* new col names */ { "firstName", "country", "email" }
} ),
RenamedCols = Table.RenameColumns(Source, TransposedLists)
in
RenamedCols