Forum Discussion
PBrabander
Sep 15, 2022Copper Contributor
Partially transpose a table
Hi fellow Excellers,
I am dealing with a table that I want to partially transpose. See table I below as an example. I want to include the weeks in the rows (see table II). I can't figure it out, can someone help me?
Cheers!
Brand | Model | Colour | Week 1-2023 | Week 2-2023 | Week 3-23 |
Apple | S32022 | Black | 1000 | 1391 | 1708 |
Apple | 13 PRO | Black | 134 | 167 | 195 |
Apple | 8 | White | 397 | 413 | 651 |
Samsung | S20 | Black | 5378 | 5689 | 5290 |
Samsung | S10 | Black | 8098 | 8134 | 8123 |
Samsung | S10e | Bronze | 6254 | 6637 | 6587 |
Samsung | S8 | White | 426 | 481 | 443 |
Nokia | G21 | Black | 129 | 176 | 198 |
Nokia | 210 | Black | 7532 | 7612 | 7751 |
Table I
Brand | Model | Colour | Date |
Apple | S32022 | Black | 1000 |
Apple | S32022 | Black | 1391 |
Apple | S32022 | Black | 1708 |
Apple | 13 PRO | Black | 134 |
Apple | 13 PRO | Black | 167 |
Apple | 13 PRO | Black | 195 |
Apple | 8 | White | 397 |
Apple | 8 | White | 413 |
Apple | 8 | White | 651 |
Samsung | S20 | Black | 5378 |
Samsung | S20 | Black | 5689 |
Samsung | S20 | Black | 5290 |
Samsung | S10 | Black | 8098 |
Samsung | S10 | Black | 8134 |
Samsung | S10 | Black | 8123 |
Samsung | S10e | Bronze | 6254 |
Samsung | S10e | Bronze | 6637 |
Samsung | S10e | Bronze | 6587 |
Samsung | S8 | White | 426 |
Samsung | S8 | White | 481 |
Samsung | S8 | White | 443 |
Nokia | G21 | Black | 129 |
Nokia | G21 | Black | 176 |
Nokia | G21 | Black | 198 |
Nokia | 210 | Black | 7532 |
Nokia | 210 | Black | 7612 |
Nokia | 210 | Black | 7751 |
Click in the source range.
On the Data tab of the ribbon, in the Get & Transform Data group, click From Table/Range.
Select all the week columns.
In the query editor, activate the Transform tab of the ribbon.
Select Unpivot Columns > Unpivot Only Selected Columns.
If you don't want the week in the final result, right-click the column with the weeks and select Remove from the context menu.
Switch back to the Home tab of the query editor, and click Close & Load.
Click in the source range.
On the Data tab of the ribbon, in the Get & Transform Data group, click From Table/Range.
Select all the week columns.
In the query editor, activate the Transform tab of the ribbon.
Select Unpivot Columns > Unpivot Only Selected Columns.
If you don't want the week in the final result, right-click the column with the weeks and select Remove from the context menu.
Switch back to the Home tab of the query editor, and click Close & Load.
- PBrabanderCopper ContributorBig thanks Hans!