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 revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
transformations:pivot [2016/06/19 19:58] dmitrytransformations:pivot [2020/01/22 04:39] dmitry
Line 2: Line 2:
  
 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: Winter Olympics medals**
 +
 +^  Country  ^  Season  ^  Medals  ^
 +| Canada  |  winter 2010  |  26  |
 +| United States  |  winter 2010  |  37  |
 +| Norway  |  winter 2010  |  23  |
 +| Germany  |  winter 2010  |  30  |
 +| Canada  |  winter 2014  |  25  |
 +| United States  |  winter 2014  |  28  |
 +| Norway  |  winter 2014  |  26  |
 +| Germany  |  winter 2014  |  19  |
 +
 +
 +Pivot on columns [Season] and [Medals]. Aggregation - Any. Result:
 +^  Country  ^  winter 2010  ^  winter 2014  ^
 +| Canada  |  26  |  25  |
 +| United States  |  37  |  28  |
 +| Norway  |  23  |  26  |
 +| 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.txt · Last modified: 2021/07/19 02:23 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki