I have a table which has a list of Id's and categories. See below:
| id | Category | Value |
|---|---|---|
| 1 | Pref 1 Region | MTO |
| 1 | Pref 1 Area | MT99 |
| 1 | Pref 1 Station | ST124 |
| 1 | Pref 2 Region | MTO |
| 1 | Pref 2 Area | MT85 |
| 1 | Pref 2 Station | ST420 |
| 1 | Pref 3 Region | BSW |
| 1 | Pref 3 Area | BS88 |
| 1 | Pref 3 Station | ST876 |
| 2 | Pref 1 Region | GRT |
| 2 | Pref 1 Area | GT34 |
| 2 | Pref 1 Station | STT555 |
| 2 | Pref 2 Region | MTO |
| 2 | Pref 2 Area | MT99 |
| 2 | Pref 2 Station | ST124 |
| 2 | Pref 3 Region | BSW |
| 2 | Pref 3 Area | BS88 |
| 2 | Pref 3 Station | ST876 |
I want to keep the Pref # Station and 'unpivot' the other categories Area and Region to separate columns, like below:
| id | Category | Value | Region | Area |
|---|---|---|---|---|
| 1 | Pref 1 Station | ST124 | MTO | MT99 |
| 1 | Pref 2 Station | ST420 | MTO | MT85 |
| 1 | Pref 3 Station | ST876 | BSW | BS88 |
| 2 | Pref 1 Station | STT555 | GRT | GT34 |
| 2 | Pref 2 Station | ST124 | MTO | MT99 |
| 2 | Pref 3 Station | ST876 | BSW | BS88 |
I've tried unpivoting columns in PowerQuery but the order isn't kept. Any help is much appreciated!