Documents and Office

How to Unpivot Data: Turning Wide Spreadsheets into Long Tables

Understand wide and long data, unpivot month columns into rows, pivot them back with sums or averages, fill down labels and split multi-value cells.

Saizul Amin
Saizul Amin2 Nov 2026 · 3 min read
How to Unpivot Data: Turning Wide Spreadsheets into Long Tables

How to Unpivot Data: Turning Wide Spreadsheets into Long Tables

Most spreadsheets are designed to be read by people. A sales report has one row per product and a column for each month, which makes it easy to scan across a year. The trouble starts when you try to analyse it. A pivot table cannot treat the twelve month columns as one field, a chart tool wants a single date column, and a database import expects one row per product per month. The solution is to change the shape of the data without changing the data itself.

Wide versus long

In wide data, one variable is spread across many columns: Jan, Feb, Mar. In long data, the same information sits in two columns: one saying which month, one saying how much. Long data has more rows and fewer columns, and each row is a single observation. Statisticians call it tidy data, and almost every analysis tool prefers it. Wide data is still the right shape for printed reports and dashboards meant for reading. So the job is not to pick one shape forever but to move between them easily.

Unpivoting step by step

Load the sheet into the Unpivot and Reshape Data Tool and add a wide to long step. Tick the identifier columns, the ones that describe each row and must stay as they are, such as Region and Product. Every other column is turned into rows, unless you tick only some of them. Give the two new columns sensible names, for example Month and Units, instead of the generic Attribute and Value. Leave skip blanks on so empty months do not become empty rows.

The preview updates as you click. A sheet with 4 products and 4 month columns becomes 16 rows, minus any blank cells.

Fill down before you unpivot

Reports often write a group label only once, leaving the rows below blank to look tidy. After unpivoting, those rows would have no region at all. Add a fill down step first and choose the column; each blank cell takes the last value above it. Steps run in order, so put fill down before the unpivot.

Pivoting back to wide

The reverse step, long to wide, is just as common: you might receive a long export from a database and need a report with a column per month. Choose the identifier columns, the column whose values should become headers and the value column. If several rows land in the same cell, for instance two orders from the same store in the same month, choose how to combine them: sum, average, count, minimum, maximum, first, last or a comma-separated list. The step reports how many cells had duplicates, which is a good check that you picked the right identifiers. Fill empty cells with 0 if the report needs numbers everywhere.

Lists in a single cell

Survey tools and some CRMs store several answers in one cell: red; blue; green. That breaks counting. A split step turns such a cell into one row per item, copying the other columns, with the separator of your choice. After splitting, a simple pivot counts how often each answer was chosen.

Transpose for the odd sideways sheet

Occasionally a sheet arrives with records as columns instead of rows, typical of copied financial statements. The transpose step swaps rows and columns in one move.

Save the recipe

Reshaping is rarely a one-off. Next month's export will look the same and need the same treatment. Save the steps as a file, or simply come back, since the tool remembers them. Load the new data and the result is ready, because steps refer to columns by name rather than position. Export to CSV for other tools or to Excel, where the original sits on a second sheet for reference.

Watch the row count

Unpivoting multiplies rows. A 50,000-row export with 24 value columns can become over a million rows, which is close to Excel's limit and slow on a phone. If that happens, unpivot only the columns you need, or filter the data first.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages