Forum Discussion
Transform Data in Power Query
- 4 years ago
Hi D3K
Try this
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rZNNboNADEavgtg2sfw7trlEDxBl13ZXVcr9F2XIEBiVLCqFFfLj8+BnuFzGN3EbyAc2Pxc5p46nkRwBsd5gMVAar6fL+H77+LwNWC8SKhTD1+3neyAFDGBkGogn44lyDnK0BoXAc8kvSQyPegI37JC4o2lOG2UG3VESw9hoyS7LaGG13DoLqG5UhFRqmRpWkF1YCnoN6yNspad1qDWLwPlHiVGINSUCmE2JTaiTljkmLc4zC32NEsxQ31HqsmTOtSx3KgyzoY7KUyqci85t5rQDnbKuuTtY1FM2nSoQ+E+driredBrUZxadMnGZhOv7rrsq8/Av+sJWncdDkwbyRrOHzfWTaHN9vCc2vru2O45+E/NPqLvO1G/icE/XXw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Status = _t, Quantity = _t, Price = _t]), #"Reordered Columns" = Table.ReorderColumns(Source,{"Status", "Quantity", "Price"}), #"Added Custom" = Table.AddColumn(#"Reordered Columns", "Phone ID", each if Text.StartsWith([Status],"+") then [Status] else null), #"Added Conditional Column" = Table.AddColumn(#"Added Custom", "ORDER Number", each if Text.StartsWith([Status], "Order") then Text.Middle([Status],6,11) else null), #"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "Date", each if Text.StartsWith([Status], "Order") then Text.Middle([Status],23,10) else null), #"Added Conditional Column2" = Table.AddColumn(#"Added Conditional Column1", "SKU ID", each if not Text.StartsWith([Status],"+") and not Text.StartsWith([Status], "Order") then [Status] else null), #"Reordered Columns1" = Table.ReorderColumns(#"Added Conditional Column2",{"Status", "Date", "Phone ID", "ORDER Number", "SKU ID", "Quantity", "Price"}), #"Filled Down" = Table.FillDown(#"Reordered Columns1",{"Date", "Phone ID", "ORDER Number"}), #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([SKU ID] <> null)), #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Status"}) in #"Removed Columns"Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
D3K it can be done, throw it in a sample pbix file and also share a sample file that can be used and will able to provide the solution.
✨ Follow us on LinkedIn and to our YouTube channel
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.
- D3K4 years agoAdvocate II
Hey parry2k
Thanky you for your attention to the topic
Here is a sample pbix via the link below
https://www.dropbox.com/s/lxq7aafbel7nyoc/Transform_Data_Sample.pbix?dl=0