Forum Discussion
Pivot table of multiple columns in PowerQuery
Hi All,
I am trying to transform multiple columns of my data set so I can express them all in one dashboard.
For the purpose of finding a solution I have simplified what I am trying to do into an example of 'Person' from a certain 'Country' and the 'date' that they bought either a 'Red', 'Green' or 'Yellow' top on.
What I am trying to achieve is one dashboard that end users can then filter by top colour to see total amounts of top colours purchased in certain dates, or countries.
Currently my data is in this format:
| ID | Name | Country | Green | Red | Blue |
| 1 | John | Brazil | 7/2/2020 | ||
| 2 | Graeme | Australia | 7/2/2020 | ||
| 3 | Rebecca | New Zealand | |||
| 4 | Sarah | Chile | 4/15/2020 | ||
| 5 | Steph | Czech Republic | 4/14/2020 | 7/2/2020 | |
| 6 | Michael | Chile | 3/3/2020 | ||
| 7 | Pablo | New Zealand | 3/6/2020 | ||
| 8 | Bart | India | 3/27/2020 | ||
| 9 | Kiran | India | 1/9/2020 |
I am thinking it would be best to use a PivotTable to get it in the form of:
| ID | Name | Country | PivotedColumn? | Green | Red | Blue |
| 1 | John | Brazil | Green | 7/2/2020 | ||
| 2 | Graeme | Australia | 7/2/2020 | 7/2/2020 | ||
| 3 | Rebecca | New Zealand | ||||
| 4 | Sarah | Chile | 4/15/2020 | |||
| 5 | Steph | Czech Republic | Green | 4/14/2020 | ||
| 5 | Steph | Czech Republic | Blue | 7/2/2020 | ||
| 6 | Michael | Chile | Red | 3/3/2020 | ||
| 7 | Pablo | New Zealand | Green | 3/6/2020 | ||
| 8 | Bart | India | Blue | 3/27/2020 | ||
| 9 | Kiran | India | Green | 1/9/2020 |
When I try to do this, it comes up with "Expression.Error: We cannot apply a Pivot operation over a table that contains columns with nested data. Please remove these columns first"
Would anyone please be able to help me with a way to get my data in the right form and visualised how I am visioning?
Thanks so much, would appreciate any help!
1 Reply
- Ashish_Mathur
Super User
Hi,
I am not sure of what visual you want to create but as a starting point, you should select the first 3 colums and select "Unpivot Other columns"