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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
chanal
Helper I
Helper I

Transform Data : many occurences with the same code (a loop case?)

Hello,

I would like to solve one problem I encounter when I have this file :  https://bit.ly/2r7wVug

I would like to transform in M those datas but there are some loop occurrences

Each time the code S1  appears, it concerns another employee. I would like to have one row for each employee and the different codes in columns.

Question : How do you think I should do ? Increment a different index for each new employee ? Would you do that in M with which formula?

 

Thank you so much for your help

Isabelle

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@chanal start a blank query and copy following code and you will get the result and take it from there

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjZU0lEK9vUM8VCK1QFyjYBcx5TEXAjPGMgzNDXUMzOH8E1AfB0TAwOFR01rIEIg/c4+jpEI7cGJSUWZeYn4TDCFmRALAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Code = _t, Values = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Code", type text}, {"Values", type text}}),
  #"Grouped Rows" = Table.Group(#"Changed Type", {"Code"}, {{"Rank", each Table.AddIndexColumn(_, "Rank", 1)}}),
    #"Expanded Rank" = Table.ExpandTableColumn(#"Grouped Rows", "Rank", {"Values", "Rank"}, {"Values", "Rank.1"}),

    #"Pivoted Column" = Table.Pivot(#"Expanded Rank", List.Distinct(#"Expanded Rank"[Code]), "Code", "Values")
in
    #"Pivoted Column"

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @chanal ,

If @parry2k solved your problem, please consider to accept  his reply as a solution  to help the other members find it more quickly.

 

Best Regards,

Icey

parry2k
Super User
Super User

@chanal start a blank query and copy following code and you will get the result and take it from there

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjZU0lEK9vUM8VCK1QFyjYBcx5TEXAjPGMgzNDXUMzOH8E1AfB0TAwOFR01rIEIg/c4+jpEI7cGJSUWZeYn4TDCFmRALAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Code = _t, Values = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Code", type text}, {"Values", type text}}),
  #"Grouped Rows" = Table.Group(#"Changed Type", {"Code"}, {{"Rank", each Table.AddIndexColumn(_, "Rank", 1)}}),
    #"Expanded Rank" = Table.ExpandTableColumn(#"Grouped Rows", "Rank", {"Values", "Rank"}, {"Values", "Rank.1"}),

    #"Pivoted Column" = Table.Pivot(#"Expanded Rank", List.Distinct(#"Expanded Rank"[Code]), "Code", "Values")
in
    #"Pivoted Column"

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Dear Parry,

 

Thank you so much for your quick answer !! It really works with my example, thank you.

 

My file is a little bit more complex than my example, so I may ask you another question later.

 

Best regards,

Isabelle

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.