We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello!
I need help please. I dont know how can I get what I need. I have this table:
| Order | Product Category |
1 | Sport |
| 1 | Fashion |
| 2 | Food |
| 2 | Sport |
I need to split the second column (Product Category) so I have this result:
| Order | Product Category 1 | Product Category 2 |
| 1 | Sport | Fashion |
| 2 | Food | Sport |
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
Solved! Go to Solution.
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
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.
Hi @Anonymous ,
Similar to this:
https://community.powerbi.com/t5/Power-Query/Duplicated-rows-to-columns/m-p/1013664#M34490
Kind regards,
JB
Hi @Anonymous ,
Similar to this:
https://community.powerbi.com/t5/Power-Query/Duplicated-rows-to-columns/m-p/1013664#M34490
Kind regards,
JB
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.
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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 10 | |
| 8 | |
| 7 | |
| 7 | |
| 5 |