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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Splitting column

Hello!

 

I need help please. I dont know how can I get what I need. I have this table:

 

OrderProduct Category

1

Sport
1Fashion
2Food
2Sport

 

I need to split the second column (Product Category) so I have this result:

OrderProduct Category 1Product Category 2
1SportFashion
2FoodSport

 

I tried crating a new column from example but it does not work.

The idea is to check the patterns of mix between the orders. Thanks for your help!

 

Kind regards

3 ACCEPTED SOLUTIONS
ImkeF
Community Champion
Community Champion

1) Duplicate "Order"-column

2) Pivot on that new column with "Product Category" as Values-column. Adjust aggregation settings to "no aggregation"

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

dax
Community Support
Community Support

Hi @Anonymous , 

You could try below M code to se whether it work or not

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQouyC8qUYrVgfDcEoszMvPzwHwjED8/PwXOgSqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Order = _t, #"Product Category" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Order", Int64.Type}, {"Product Category", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Order"}, {{"Product Category", each Text.Combine([Product Category], ","), type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Grouped Rows", "Product Category", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Product Category.1", "Product Category.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Product Category.1", type text}, {"Product Category.2", type text}})
in
    #"Changed Type1"

Best Regards,
Zoe Zhi

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

Anonymous
Not applicable

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

Similar to this:

https://community.powerbi.com/t5/Power-Query/Duplicated-rows-to-columns/m-p/1013664#M34490

 

Kind regards,

JB

dax
Community Support
Community Support

Hi @Anonymous , 

You could try below M code to se whether it work or not

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQouyC8qUYrVgfDcEoszMvPzwHwjED8/PwXOgSqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Order = _t, #"Product Category" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Order", Int64.Type}, {"Product Category", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Order"}, {{"Product Category", each Text.Combine([Product Category], ","), type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Grouped Rows", "Product Category", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Product Category.1", "Product Category.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Product Category.1", type text}, {"Product Category.2", type text}})
in
    #"Changed Type1"

Best Regards,
Zoe Zhi

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

ImkeF
Community Champion
Community Champion

1) Duplicate "Order"-column

2) Pivot on that new column with "Product Category" as Values-column. Adjust aggregation settings to "no aggregation"

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.