User Tools

Site Tools


transformations:pivot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
transformations:pivot [2016/06/20 00:01]
dmitry
transformations:pivot [2020/01/22 09:39] (current)
dmitry
Line 3: Line 3:
 Creates a matrix table using values in one column as column labels, and values in another column as the matrix column's values. This transformation is opposite to [[transformations:unpivot|Unpivot]]. Creates a matrix table using values in one column as column labels, and values in another column as the matrix column's values. This transformation is opposite to [[transformations:unpivot|Unpivot]].
  
-EXAMPLE +**Example: Winter Olympics medals**
- +
-**Table:** Winter Olympics medals+
  
 ^  Country  ^  Season  ^  Medals  ^ ^  Country  ^  Season  ^  Medals  ^
Line 18: Line 16:
  
  
-**Transformation:** Pivot on columns [Season] and [Medals]. Aggregation - Any. +Pivot on columns [Season] and [Medals]. Aggregation - Any. Result:
- +
-**Result:**+
 ^  Country  ^  winter 2010  ^  winter 2014  ^ ^  Country  ^  winter 2010  ^  winter 2014  ^
 | Canada  |  26  |  25  | | Canada  |  26  |  25  |
Line 26: Line 22:
 | Norway  |  23  |  26  | | Norway  |  23  |  26  |
 | Germany  |  30  |  19  | | Germany  |  30  |  19  |
 +
 +Note that grouping works implicitly in the "Pivot" action. Groups are formed by combination of values in other columns that not labels or data. Values in a group are aggregated into 1 row. For instance in the example above, column [Country] was used for implicit grouping, because two other columns, [Season] and [Medals], were used for labels and data respectively.
 +
 +If a pivoted dataset has only two columns, one of which is used for data, and the other for labels), then the resulting dataset will always have only 1 row.
  
 **See also** **See also**
   * [[transformations:unpivot|Unpivot]]   * [[transformations:unpivot|Unpivot]]
transformations/pivot.1466380899.txt.gz · Last modified: 2016/06/20 00:01 by dmitry