Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

make Column categories as my column headers

i have a column in my data that is labeled "Channel", it has "in-person", "phone", "email", "video"

 

i want to make a subtable that shows those categories as column header and corresponding data will populate underneath

  • Hi Anonymous ,

     

    How about this.

     

    Before:

     

    After:

     

    Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WyszTLUgtKs7PU4rViVYqyMjPSwWzyjJTUvPBrNTcxMwcpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Channel = _t]),
        #"Transposed Table" = Table.Transpose(Source),
        #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
        #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"in-person", type any}, {"phone", type any}, {"video", type any}, {"email", type any}})
    in
        #"Changed Type"


    If this is not exactly what you were looking for, consider to use the pivot feature (Under the transform tab). Pivoting might help in case you have multiple columns next to your channel column.

     

    Let me know if this helps 🙂

     

    /Tom
    https://www.tackytech.blog/
    https://www.instagram.com/tackytechtom/

1 Reply

  • tackytechtom's avatar
    tackytechtom
    Most Valuable Professional

    Hi Anonymous ,

     

    How about this.

     

    Before:

     

    After:

     

    Here the code in Power Query M that you can paste into the advanced editor (if you do not know, how to exactly do this, please check out this quick walkthrough)

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WyszTLUgtKs7PU4rViVYqyMjPSwWzyjJTUvPBrNTcxMwcpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Channel = _t]),
        #"Transposed Table" = Table.Transpose(Source),
        #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
        #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"in-person", type any}, {"phone", type any}, {"video", type any}, {"email", type any}})
    in
        #"Changed Type"


    If this is not exactly what you were looking for, consider to use the pivot feature (Under the transform tab). Pivoting might help in case you have multiple columns next to your channel column.

     

    Let me know if this helps 🙂

     

    /Tom
    https://www.tackytech.blog/
    https://www.instagram.com/tackytechtom/