Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I am in a bind trying to transpose my table which appears as below and would greatly appreciate the help. I would like to transpose the StatusName and StatusTime so that the end product is as shown below the main table. That way, I can calculate the time differences between the status names.
CustomerId | DeliveryId | DocumentId | ShortId | StatusName | StatusTime |
2 | 25 | 5 | CPU6096178 | allocated | 12/3/2020 20:08 |
2 | 25 | 5 | CPU6096178 | awaitingPickup | 12/3/2020 20:08 |
2 | 25 | 5 | CPU6096178 | complete | 12/3/2020 22:52 |
2 | 25 | 5 | CPU6096178 | delivered | 12/3/2020 22:52 |
2 | 25 | 5 | CPU6096178 | inProgress | 12/3/2020 20:08 |
2 | 25 | 5 | CPU6096178 | picked | 12/3/2020 22:52 |
2 | 25 | 5 | CPU6096178 | sourcingCourier | 12/3/2020 20:08 |
2 | 25 | 60 | CPU1265194 | allocated | 11/10/2020 19:25 |
2 | 25 | 60 | CPU1265194 | awaitingPickup | 11/10/2020 19:25 |
2 | 25 | 60 | CPU1265194 | complete | 11/10/2020 23:36 |
2 | 25 | 60 | CPU1265194 | delivered | 11/10/2020 23:36 |
2 | 25 | 60 | CPU1265194 | inProgress | 11/10/2020 19:25 |
2 | 25 | 60 | CPU1265194 | inTransit | 11/10/2020 22:19 |
2 | 25 | 60 | CPU1265194 | picked | 11/10/2020 22:19 |
2 | 25 | 60 | CPU1265194 | pickedUp | 11/10/2020 22:19 |
2 | 25 | 60 | CPU1265194 | sourcingCourier | 11/10/2020 19:25 |
62 | 9 | 19 | CPU4702103 | allocated | 10/13/2020 22:27 |
62 | 9 | 19 | CPU4702103 | awaitingPickup | 10/13/2020 22:27 |
62 | 9 | 19 | CPU4702103 | complete | 10/14/2020 0:29 |
62 | 9 | 19 | CPU4702103 | delivered | 10/14/2020 0:29 |
62 | 9 | 19 | CPU4702103 | delivered | 10/14/2020 0:32 |
62 | 9 | 19 | CPU4702103 | dispatched | 10/13/2020 22:40 |
62 | 9 | 19 | CPU4702103 | inProgress | 10/13/2020 22:27 |
62 | 9 | 19 | CPU4702103 | inTransit | 10/13/2020 23:31 |
62 | 9 | 19 | CPU4702103 | picked | 10/13/2020 23:31 |
62 | 9 | 19 | CPU4702103 | pickedUp | 10/13/2020 23:31 |
62 | 9 | 19 | CPU4702103 | sourcingCourier | 10/13/2020 22:27 |
I would like it to appear as below
CustomerId | DeliveryId | DocumentId | ShortId | allocated | awaitingPickup | complete | delivered | inProgress | inTransit | picked | sourcingCourier | PickedUp |
2 | 25 | 5 | CPU6096178 | 12/3/2020 20:08 | 12/3/2020 20:08 | 12/3/2020 22:52 | 12/3/2020 22:52 | 12/3/2020 20:08 | Null | 12/3/2020 22:52 | 12/3/2020 20:08 | Null |
2 | 25 | 60 | CPU1265194 | 11/10/2020 19:25 | 11/10/2020 19:25 | 11/10/2020 23:36 | 11/10/2020 23:36 | 11/10/2020 19:25 | 11/10/2020 22:19 | 11/10/2020 22:19 | 11/10/2020 19:25 | 11/10/2020 22:19 |
Thank you very much.
Solved! Go to Solution.
Hi,
You can use Pivot table transformation in the power query.
Select column Status name and Status Time.
Click on Pivot Column
Select Pivot table properties as follows
You will get the following results
Regards,
Sayali
If this post helps, then please consider Accept it as the solution to help others find it more quickly.
Proud to be a Super User!
Simply group rows by CustomerId/DeliveryId/DocumentId/ShortId and pivot the derived table; then it's done.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rdO9boMwEAfwV6mYI3F3BhN7zQswlCnKgIiVWqWADGlfv0YMYEB1jDoARuh3/rg/12tE0Smi1N7G65IXHATH7Gxfyrpuq3JQdztGillMQPBGIOEc3U5/yp9SD7p55Lr6fHbBvGq/uloNyoUkU/LAu6r1tzLrFb8gdZOb9mFU3wevtrObPDBj3z5NZc/oYp9aGd+0HKYCSDxFkazbgzHCZFFIC3x206DAAssWzZSYZNxHnSYFWrdNgWvWzbspm14Pq4lJovDZucmHYNEdoDsJ2dsxH0uI8auYKiQZEAJbRwRinONJmdduIhJYYBkRS5OJgiThk05C/oky8lLdd+VQfeycVgI+7AYz8KScYC6s/SPQZ+dgHoLFurOv0J1gbnZ8+wU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CustomerId = _t, DeliveryId = _t, DocumentId = _t, ShortId = _t, StatusName = _t, StatusTime = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"CustomerId", Int64.Type}, {"DeliveryId", Int64.Type}, {"DocumentId", Int64.Type}, {"ShortId", type text}, {"StatusName", type text}, {"StatusTime", type datetime}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"CustomerId", "DeliveryId", "DocumentId", "ShortId"}, {{"ar", each Table.Pivot(_, List.Distinct(#"Changed Type"[StatusName]), "StatusName", "StatusTime")}}),
#"Expanded ar" = Table.ExpandTableColumn(#"Grouped Rows", "ar", {"allocated", "awaitingPickup", "complete", "delivered", "inProgress", "picked", "sourcingCourier", "inTransit", "pickedUp", "dispatched"}, {"allocated", "awaitingPickup", "complete", "delivered", "inProgress", "picked", "sourcingCourier", "inTransit", "pickedUp", "dispatched"})
in
#"Expanded ar"
But to my knowledge, the original one-dimensional table functions well in PBI data model in most cases; such transformations sometimes are redundant.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Thank you @CNENFRNL for your time. This proved to be too complex for me, still a novie in this, and instead went with pivot described below by @sayaliredij .
Hi,
You can use Pivot table transformation in the power query.
Select column Status name and Status Time.
Click on Pivot Column
Select Pivot table properties as follows
You will get the following results
Regards,
Sayali
If this post helps, then please consider Accept it as the solution to help others find it more quickly.
Proud to be a Super User!
We have an option in matrics table, its very easy to transpose the coloumns. no need of complex Pivot options. just a switch button would help to achive thisHighlighted
So simple, but before your post it took me hours (!) to replace this function using measures.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
142 | |
77 | |
63 | |
51 | |
47 |
User | Count |
---|---|
215 | |
85 | |
61 | |
61 | |
60 |