Forum Discussion

prafael's avatar
prafael
Frequent Visitor
3 years ago
Solved

Table Transformation - Transformation preserving categories

Hello, happy new year everyone!

Could you help me with this question?

I have the table below:

 

col1col2
ax
ay
by
bx
cz

 

and I want to transform it into the table below:

 

col1col3
axy
byx
cz

 

its possible? Thanks

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi prafael ,

     

    Here I suggest you to use group by function and create a custom column in Power Query Editor.

    = Table.Group(#"Changed Type", {"col1"}, {{"Col3", each Text.Combine([col2]), type nullable text}})

    Whole M code:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUapQitWBsCrBrCQUFkQ2GciqUoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [col1 = _t, col2 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"col1", type text}, {"col2", type text}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"col1"}, {{"Col3", each Text.Combine([col2]), type nullable text}})
    in
        #"Grouped Rows"

    My Sample:

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi prafael ,

     

    Here I suggest you to use group by function and create a custom column in Power Query Editor.

    = Table.Group(#"Changed Type", {"col1"}, {{"Col3", each Text.Combine([col2]), type nullable text}})

    Whole M code:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUapQitWBsCrBrCQUFkQ2GciqUoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [col1 = _t, col2 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"col1", type text}, {"col2", type text}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"col1"}, {{"Col3", each Text.Combine([col2]), type nullable text}})
    in
        #"Grouped Rows"

    My Sample:

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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