Unpivot
Reshape wide table to long (columns to rows)
What It Does
Unpivot is the opposite of Pivot. It melts several columns into two: one for the original column name, one for the value. Other columns are repeated for each unpivoted row. Useful when columns like jan_revenue, feb_revenue should be rows for charting over time.
How to Use It
Opening the Panel
Click the + button in the toolbar or press the operation picker, then search for "Unpivot". It's in the Aggregate group.
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
Value columns | Multi-select | Yes | Columns whose values stack into a single column |
Name column | Text | Yes | Output column for the source column name |
Value column | Text | Yes | Output column for the value |
SQL generated under the hood
UNPIVOT data ON jan_revenue, feb_revenue, mar_revenue INTO NAME month VALUE revenue
Related Operations
- Pivot - Pivot table (rows to columns)
- Window Function - Rank, row number, lead, lag
- Smallest - Get nth smallest value as a column