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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
kburata
Regular Visitor

Transposing Tables

Hi,

 

Need to convert table from this

 

KeyValue
Rank17.5309867
DocId701135570498039
TitleAppointment 
AuthorDylan
Rank17.5309867
DocId7011355705149
TitleMeet
Author

Steph

 

to this

 

RankDocIdTitleAuthor
17.5309867701135570498039Appointment Dylan
17.53098677011355705149MeetSteph

 

Any help would be much appreciated.

 

Regards,

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

As long as each bracket of rows starts with "Rank", you might want to try this solution,

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkrMy1bSUTI01zM1NrC0MDNXitWJVnLJT/ZMAQqbGxgaGpuamhuYWFoYGFuC5UIyS3JSgXKOBQX5mXklual5JYcWgGUcS0sy8ouAUi6VOYl5YCEijTc1NEE13Dc1tQTVzOCS1IIMpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Key = _t, Value = _t]),
    Grouped = Table.RemoveColumns(Table.Group(Source, "Key", {"ar", each Table.PromoteHeaders(Table.Transpose(_))}, 0, (x,y) => Number.From(y="Rank")), {"Key"}),
    #"Expanded ar" = Table.ExpandTableColumn(Grouped, "ar", {"Rank", "DocId", "Title", "Author"}, {"Rank", "DocId", "Title", "Author"})
in
    #"Expanded ar"

Screenshot 2021-05-05 091924.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Community Champion
Community Champion

As long as each bracket of rows starts with "Rank", you might want to try this solution,

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkrMy1bSUTI01zM1NrC0MDNXitWJVnLJT/ZMAQqbGxgaGpuamhuYWFoYGFuC5UIyS3JSgXKOBQX5mXklual5JYcWgGUcS0sy8ouAUi6VOYl5YCEijTc1NEE13Dc1tQTVzOCS1IIMpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Key = _t, Value = _t]),
    Grouped = Table.RemoveColumns(Table.Group(Source, "Key", {"ar", each Table.PromoteHeaders(Table.Transpose(_))}, 0, (x,y) => Number.From(y="Rank")), {"Key"}),
    #"Expanded ar" = Table.ExpandTableColumn(Grouped, "ar", {"Rank", "DocId", "Title", "Author"}, {"Rank", "DocId", "Title", "Author"})
in
    #"Expanded ar"

Screenshot 2021-05-05 091924.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors