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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors