Pivot column is a feature available in Power Query which allows you turn rows to columns.
Basically, Power Query groups each unique values and performs an aggregation that you specify such as sum, max, min, count, average and so on.. for each value, and pivots the column into a new table.
Let see , how to turn rows into columns using pivot column feature in Power Query step by step.
You can see, here we have a sample dataset named Item_Sales.
|Samsung Galaxy F41||2018||6700|
|Iphone 12 Pro||2020||1500|
|Samsung Galaxy F41||2019||5654|
|Samsung Galaxy F41||2020||9587|
Lets pivot the Year based on Sold Quantity using a Pivot Column feature of Power Query.
In Ribbon bar, Inside Home tab, click on Transform data, as shown below.
Now you will see that a Power Query Editor Opens, there you can transform your data.
As we have to pivot the Year column so just select Year column first as shown below.
Now Inside the Transform tab, click on Pivot Column as shown below.
Once you click on Pivot Column, you will see a Pivot Column dialog box opens.
In Values column : Select a column from values column drop down list, here we have selected a Sold Quantity, as we want to get the total number of Sold Quantity of all Items by Year.
In Advance Option, Aggregate Value function : Specify an Aggregate Value function, as we want to see the total number of sold quantity so selected a SUM aggregate function for the calculation.
After that click on OK button, and you will see a rows is turned into columns.
Now you have a pivot table, which display the Total sum of Sold Quantity of all Items by Year.
You will also notice that there is a null values in pivot table for some Item in particular year, which means no sales recorded in this year for that particular item.
In case, if you want to sort the column order in pivot table as you can see after column 2018 the next column is 2020 instead of column 2019.
As you can see, the column 2019 is the last column in pivot table which should have come before 2020.
So, just select column 2019 and then expand Move drop down, and click on Left.
Now you can see, all the year columns in Pivot table are in order.
If you have more columns then you can use similar way to sort the column order using Move feature. You can also move column to right, To beginning and To end.
686 total views, 7 views today