# Unpivot a table

Shape / table

columns to rows, melt

Page: <https://meridian.online/operations/unpivot-a-table>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

columns to rows

It reads the `customers` table the proofs share. Create it first:

```sql
CREATE TABLE customers AS SELECT * FROM (VALUES
  ('Alice Ng',    'retail',    DATE '2025-06-01', 52.52, 13.40),
  ('Bob Okafor',  'wholesale', DATE '2025-09-15', 48.85,  2.35),
  ('Carla Diaz',  'retail',    DATE '2025-11-30', 40.42, -3.70),
  ('Frank Moore', 'retail',    DATE '2026-01-01', 51.51, -0.13)
) t(customer, segment, joined, lat, lon);
```

Then run the statement:

```sql
CREATE TEMP TABLE result AS
UNPIVOT (SELECT customer, lat, lon FROM customers) ON lat, lon INTO NAME measure VALUE reading;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT count(*) = 8 AND count(DISTINCT measure) = 2 AND max(reading) FILTER (WHERE customer = 'Alice Ng' AND measure = 'lat') = 52.52 FROM result)) THEN 'as expected' ELSE error('four customers and two measures did not become eight rows') END AS verdict;
```

It needs nothing installed beyond DuckDB itself.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

- Azure Data Factory: [`Unpivot`](https://learn.microsoft.com/en-us/azure/data-factory/data-flow-unpivot) (read 2026-09-27)
- Alteryx Designer: [`Arrange`](https://help.alteryx.com/current/en/designer/tools/transform/arrange-tool.html) (read 2026-09-27)
- Alteryx Designer: [`Transpose`](https://help.alteryx.com/current/en/designer/tools/transform/transpose-tool.html) (read 2026-09-27)
- Alteryx Designer: [`Transpose In-DB`](https://help.alteryx.com/current/en/designer/tools/laboratory/transpose-in-db-tool.html) (read 2026-09-27)
- dbt-utils: [`unpivot`](https://raw.githubusercontent.com/dbt-labs/dbt-utils/main/README.md) (read 2026-09-27)
- DuckDB: [`UNPIVOT`](https://duckdb.org/docs/current/sql/statements/unpivot) (read 2026-09-27)
- Duckle: [`Unpivot`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- EasyMorph: [`Unpivot`](https://help.easymorph.com/doku.php?id=transformations:unpivot) (read 2026-09-27)
- AWS Glue: [`Unpivot Columns To Rows`](https://docs.aws.amazon.com/glue/latest/dg/transforms-unpivot-columns-to-rows.html) (read 2026-09-27)
- KNIME Analytics Platform: [`Unpivot`](https://api.hub.knime.com/nodes/*OrsWDmrgrJ2VEX6h?details=full) (read 2026-09-27)
- OpenRefine: [`Transpose cells across columns into rows…`](https://openrefine.org/docs/manual/transposing#transpose-cells-across-columns-into-rows) (read 2026-09-27)
- Polars: [`DataFrame.melt`](https://docs.pola.rs/api/python/stable/reference/dataframe/modify_select.html) (read 2026-09-27)
- Polars: [`DataFrame.unpivot`](https://docs.pola.rs/api/python/stable/reference/dataframe/modify_select.html) (read 2026-09-27)
- Power Query M: [`Table.Unpivot`](https://learn.microsoft.com/en-us/powerquery-m/table-functions#column-operations) (read 2026-09-27)
- Power Query M: [`Table.UnpivotOtherColumns`](https://learn.microsoft.com/en-us/powerquery-m/table-functions#column-operations) (read 2026-09-27)
- RapidMiner Studio: [`De-Pivot`](https://docs.rapidminer.com/latest/studio/operators/blending/table/rotation/de_pivot.html) (read 2026-09-27)
- Tableau Prep: [`Pivot`](https://help.tableau.com/current/prep/en-us/prep_pivot.htm) (read 2026-09-27)
- Tableau Prep: [`Pivot columns to rows`](https://help.tableau.com/current/prep/en-us/prep_pivot.htm) (read 2026-09-27)
- Tableau Prep: [`Use wildcard search to pivot`](https://help.tableau.com/current/prep/en-us/prep_pivot.htm) (read 2026-09-27)
- Trifacta: [`Unpivot`](https://help.alteryx.com/aac/en/trifacta-classic/reference/transformation-reference.html) (read 2026-09-27)
- Trifacta: [`Unpivot Transform`](https://help.alteryx.com/aac/en/trifacta-classic/wrangle-language/language-appendices/transforms.html) (read 2026-09-27)
- VisiData: [`melt`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/melt.py#L97) (read 2026-09-23)
- VisiData: [`melt-regex`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/melt.py#L99) (read 2026-09-23)
