Converting Columns to Rows Using the Pivot Transform

Objective

After completing this lesson, you will be able to convert columns to rows using the Pivot transform.

The Pivot Transform

In ETL pipelines, source data often requires reshaping to meet the requirements of target systems or reporting layers. You can transform data structures—such as converting columns to rows or vice versa—without writing complex custom code.

SAP Data Services provides two complementary Data Integrator transforms for this purpose: Pivot and Reverse Pivot.

The Pivot transform rotates specific columns into rows. It normalizes wide, horizontal datasets into a vertical format by creating a new row for each value in a pivot column. For example, you can convert multiple discount-type columns into individual records (one row per discount per payment term) to simplify downstream processing or joins.

The image illustrates a transformation of a discount table, where the input table on the left, showing quantities and corresponding percentage discounts for three different customer types (Net 10, Net 20, Net 30), is converted into an output table on the right, which lists each quantity and customer type combination individually along with their respective discounts.

The Reverse Pivot transform performs the opposite operation: it aggregates data from multiple rows into a single row. It generates new columns based on the unique values of a pivot axis. This is useful for creating matrix-like layouts, such as consolidating quarterly sales records into a single store record with separate columns for each quarter.

The image illustrates a transformation of a quarterly sales table, where the input table on the left, showing sales for three stores in four rows each, corresponding to the four quarters, is converted into an output table on the right, which lists each store and its quarterly sales on a single row each.

Pivot Transform Options

The following table describes the options available in the Pivot transform:

Pivot Transform Options

OptionDescription

Pivot Sequence Column

Specifies a name for the column that stores an incrementing sequence number for each row generated from a pivot column.

Non-Pivot Columns

Identifies source columns to be passed to the target without modification.

Pivot Set

Defines a group of pivot columns, a pivot data field, and a pivot header name for each set.

Data Column Field

Specifies the column that will contain the values from the pivoted columns.

Header Column

Specifies the column that will store the original names of the pivoted columns.

Pivot Columns

Identifies the specific columns to be rotated into rows. These are described by the Header Column and Data Column Field.

Converting Columns to Rows Using the Pivot Transform

Follow this simulation to learn how to convert columns to rows using the Pivot transform.

Summary

In this lesson, you learned how to reshape data using SAP Data Services transforms:

  • Reshape data to meet target system requirements using the Pivot or Reverse Pivot transforms without custom code.
  • Use the Pivot transform to rotate columns into rows, normalizing wide datasets into a vertical format.
  • Use the Reverse Pivot transform to combine data from multiple rows into a single row by generating new columns.
  • Configure Pivot Sets, Data Column Fields, and Header Columns to map source data to the target schema.