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
YoussefN
Regular Visitor

Multiple rows in different columns

Table I wantTable I wantTable I haveTable I have

Hi all,

 

I Have a large dataset that contains an object number and a location (place, area, street) In the dataset this is on line level  as you can see in the first table. But I want it structurend in different columns as shown in the seccond table. So that I have 4 columns.

I really would appreciate your help.

 

2 ACCEPTED SOLUTIONS

Please see the comments in the code for the steps to be taken:

 

let
// Your source data Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VY2xCsJADEB/JdzcxbNfoAguddBJSodAgz1aErik+vveWYg6vpe8pO/DLjThIGrCYWg2PBJbJseriNKTFliQNxuLPcvqUeWbrDaBpvG70mG2xDAnfoCWi2Sf0f7/Y8UTqtXWRRt/i7aYC73gLnl20SFPaIbsJvLo1fAG", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Object = _t, Location = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Object", Int64.Type}, {"Location", type text}}), // Add Index column
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1), // Transform index column with modulo, value 3
#"Calculated Modulo" = Table.TransformColumns(#"Added Index", {{"Index", each Number.Mod(_, 3), type number}}), // Pivot on that new column, taking "Location" into values. If you do this by hand, make sure to disable aggregation in the advanced options ("Don't Aggregate".
#"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Calculated Modulo", {{"Index", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Calculated Modulo", {{"Index", type text}}, "en-US")[Index]), "Index", "Location") in #"Pivoted Column"

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

Sure, just pivot on that column instead of the newly created and rename the resulting columns afterwards.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

10 REPLIES 10

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.