Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Moving Rows into columns with Unique ID

Hello, I have a much larger set of data similar to below. I want to get it so Unique ID is in the row, and the Course Title is in the column.    So from this: Title Learner ID Learner Name S...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,
    Thanks for amitchandak  reply.
    Here some steps that I want to share, you can check them if they suitable for your requirement.
    Here is my test data:

    Click "Transform data" and open power query
    Select the Title column and select the pivot column in the Transform toolbar, then in the screen that opens select Status in the value column and select the Don't Aggregate option in the Aggregate Value function.Select the Title column and select the pivot column in the Transform toolbar, then in the screen that opens select Status in the value column and select the Don't Aggregate option in the Aggregate Value function.

    Final output

    You can also use this m code in advanced editor

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZCxDsIgEIZfpWHuIvgC2g420cZYt6bDWS9KpGCAmvj2QtKhQAe7/Lk7/v/ycW1LrtwKJDk5ImiJOqvKWVPD4N8aC3Y0rij5hxuuJOnylhRq1AazjZtXpde9ujkt1PAWaPHu6jN8tRIitVO/FTQ8o8DhknqZ053gPUbeBgSa1L51egL98o3sJ/80Q8vlYx6hEXyQWKCnCX2QCPFpgh+YE34a889/u4jP1t2erbg9WwnP/oTvfg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}, {"(blank).4", type text}}),
        #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
        #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Title", type text}, {"Learner ID", type text}, {"Learner Name", type text}, {"Status", type text}, {"Division", type text}}),
        #"Pivoted Column" = Table.Pivot(#"Changed Type1", List.Distinct(#"Changed Type1"[Title]), "Title", "Status")
    in
        #"Pivoted Column"

     

    Best regards,

    Albert He

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly