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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
prafael
Frequent Visitor

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

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

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:

RicoZhou_1-1672993249543.png

Result is as below.

RicoZhou_0-1672993229167.png

 

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.

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

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:

RicoZhou_1-1672993249543.png

Result is as below.

RicoZhou_0-1672993229167.png

 

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.

amitchandak
Super User
Super User

@prafael , This should be able to help, do not use delimiter

Concatenate Text- Measure, DAX Table, and Power Query Table: https://youtu.be/xAh3tz1qo24

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.