Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I have a table with the following structure:
ID | Action1 | Action2 | Action3 | Action1DueDate | Action2DueDate | Action3DueDate | Action1Completed | Action2Completed | Action3Completed |
1 | a | b | c | 01/01/2023 | 04/01/2023 | 07/01/2023 | 10/01/2023 | 13/01/2023 | 16/01/2023 |
2 | d | e | f | 02/01/2023 | 05/01/2023 | 08/01/2023 | 11/01/2023 | 14/01/2023 | 17/01/2023 |
3 | g | h | i | 03/01/2023 | 06/01/2023 | 09/01/2023 | 12/01/2023 | 15/01/2023 | 18/01/2023 |
I want to transform it so each action has its own row like follows:
ID | Action | Due Date | Completed |
1 | a | 01/01/2023 | 10/01/2023 |
1 | b | 04/01/2023 | 13/01/2023 |
1 | c | 07/01/2023 | 16/01/2023 |
2 | d | 02/01/2023 | 11/01/2023 |
2 | e | 05/01/2023 | 14/01/2023 |
2 | f | 08/01/2023 | 17/01/2023 |
3 | g | 03/01/2023 | 12/01/2023 |
3 | h | 06/01/2023 | 15/01/2023 |
3 | i | 09/01/2023 | 18/01/2023 |
I could create separate queries for Action, Due Date and Completed. Unpivoting each and then merging back together with the ID and the action number. But that doesn't feel like a great solution. Is there a better way of doing this?
Solved! Go to Solution.
Hi,
let
Source = YourSource,
Unpivot = Table.UnpivotOtherColumns(Source, {"ID"}, "Attribute", "Value"),
Group = Table.Group(Unpivot, {"ID"}, {{"Data", each Table.FromColumns(List.Split([Value],3), {"Action", "DueDate", "Completed"})}}),
Expand = Table.ExpandTableColumn(Group, "Data", {"Action", "DueDate", "Completed"}, {"Action", "DueDate", "Completed"})
in
Expand
Stéphane
Thanks, that works perfectly!
Hi,
let
Source = YourSource,
Unpivot = Table.UnpivotOtherColumns(Source, {"ID"}, "Attribute", "Value"),
Group = Table.Group(Unpivot, {"ID"}, {{"Data", each Table.FromColumns(List.Split([Value],3), {"Action", "DueDate", "Completed"})}}),
Expand = Table.ExpandTableColumn(Group, "Data", {"Action", "DueDate", "Completed"}, {"Action", "DueDate", "Completed"})
in
Expand
Stéphane
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
29 | |
12 | |
12 | |
11 | |
8 |
User | Count |
---|---|
53 | |
27 | |
15 | |
14 | |
13 |