Shape · Summarize and reshape
Unpivot
Turns chosen columns into rows of name and value pairs. For example, Jan, Feb and Mar columns become month and sales rows.
Also known as: Melt, wide to long, transpose
How it works
Choose the Columns to unpivot; every column you do not unpivot is kept on each output row, so the Keep as rows (id columns) picker does not change the output. Each chosen column becomes one row per input row, with the column's name in the Attribute column name (name by default) and its cell in the Value column name (value by default). Null cells are kept as rows, not dropped. Columns of one type keep it; mixing numbers and text in the melted columns gives text. Rows come out in input order, one block of pairs per input row. Pivot does the reverse.
Inputs and outputs
Inputs
data— Table
Outputs
data— Table
Settings
The Attributes panel of Unpivot, as in the app: the controls work, but nothing runs — there is no data behind it.
The same settings, as the Assistant writes them
{
idColumns: string[]
valueColumns: string[]
nameColumn: string
valueColumn: string
}idColumns = the only columns kept beside name/value (empty = keep every column not folded); nameColumn = attribute column (folded field names), valueColumn = value column; both optional (default name/value, numeric suffix on collision)
Example
A sheet has one column per month. Keep store as rows, unpivot Jan, Feb and Mar, and name the attribute column month and the value column sales.
| store | month | sales |
|---|---|---|
| Downtown | Jan | 120 |
| Downtown | Feb | 95 |
| Downtown | Mar | 130 |