Pivot and Unpivot Transformations
Pivoting data means separating different row values from one column into separate columns; if it is the other way round, Unpivot terminology is used. The following screenshot shows a sample of Pivot data:
As the previous data shows, there are multiple rows for each ProductID, but different OrderQuantity entries for different OrderYear entries in each row. A Pivot can be applied on this data and it can fetch out each different OrderYear entry as a different column and the value of each equivalent OrderQuantity can appear in its appropriate column, and as a result, one row will be needed for each product. The following screenshot shows the pivoting result of such a scenario:
In this recipe, we will use the Pivot Transformation for reading the list of products with their quantity of sales each year from the AdventureWorks2012
database with ProductID, Name, OrderYear, and OrderQuantity columns and then pivot the data into multiple columns for each OrderYear entry...