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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
GDE
Regular 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!

2 ACCEPTED SOLUTIONS
robrog37
Regular Visitor

Table.ToRows(Table.FromList(List))

View solution in original post

mapelli
Frequent Visitor

= List.Zip( { your_list } )

example: List.Zip( { {1, 2, 3} } ) = { {1}, {2}, {3} } 

View solution in original post

7 REPLIES 7
mapelli
Frequent Visitor

= List.Zip( { your_list } )

example: List.Zip( { {1, 2, 3} } ) = { {1}, {2}, {3} } 

GDE
Regular Visitor

IMHO, this is the best one, I've seen so far. 🙂

mapelli
Frequent 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= "john.doe@company.com"],
[name_1= "Juan", address_2= "MX", id_3= "juan.torres@factory.net"],
[name_1= "João", address_2= "BR", id_3= "joao.silva@empresa.com.br"]
}),

TransposedLists = List.Zip( { /* current column names: */ Table.ColumnNames(Source),
/* new col names */ { "firstName", "country", "email" }
),

RenamedCols = Table.RenameColumns(Source, TransposedLists)
in
RenamedCols

Zubair_Muhammad
Community Champion
Community Champion

@GDE 

 

let
    Source = {1, 2, 3},
    New= List.Generate(()=>[a={},b=0], each [b] <= List.Count(Source), each [a={Source{b}},b=[b]+1], each [a])
in
    New

Regards
Zubair

Please try my custom visuals

Wow! That is a mighty function right there! A little (a lot) out of my leaugue...
Respect!

@GDE 

another option:

List.Transform( yourList_, each {_} )

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

robrog37
Regular Visitor

Table.ToRows(Table.FromList(List))

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.