Unpivot & Reshape

A column for every month reads beautifully and charts terribly. This turns those wide tables tall — one row per month instead of a column each — which is the shape a pivot table or a chart can actually use.

How to use it

Tick the columns that identify a row, the name, the region, the product, and everything left over is treated as a measurement.

  1. Paste your table It needs a header row, because those headings are what become values when the table is turned on its side.
  2. Tick the columns that identify a row Usually the first one or two. Those are repeated down the page; every other column becomes a name and a value.
  3. Check the row count Twelve month columns across a hundred rows should give twelve hundred rows back. If it does not, a column is ticked that should not be.
Full instructions

Which columns describe the row

everything not ticked is treated as data
Paste some data and the columns appear here.

Your table

paste a CSV with a header row

Reshaped

In depth

Reshaping data between wide columns and long rows

A table with a column for every month is easy to read but impossible to chart, group, or feed into a pivot table. The reverse shape, one row per measurement with the month stored in a cell, is what those tools need. This article explains both directions of the Unpivot and Reshape tool, walks through a real reshaping job, and shows how to avoid the collision problem that silently eats rows when you go back the other way.

Screenshot: The same numbers in the shape tools expect
The same numbers in the shape tools expect as it appears when the page opens.

Why the shape of a table matters

There are two common ways to lay out the same numbers. Wide format puts each period or category in its own column: Jan, Feb, Mar across the top, one row per product. Long format uses just two columns for those values, typically called name and value, and repeats the product on every row. A table with five products and twelve months has five rows in wide format and sixty in long format.

Wide format is designed for reading. You scan across a row and see the whole year at a glance. Long format is designed for machines. A charting library, a pivot table, a SQL GROUP BY query, or a data visualization tool needs the category in a cell it can filter and group by, not hidden in a column heading. The heading is a label, not a value, and most tools cannot reach it. The Unpivot and Reshape tool converts between the two shapes, in both directions, entirely on your own device.

Going from wide to long

Set the Direction dropdown to Wide to long. Paste your CSV. It must have a header row, because the column headings are what become values in the new name column. Once the data appears, a panel labelled Which columns describe the row shows a checkbox for every column found in the header.

Tick the columns that identify each row. These are usually the first one or two: the product name, the region, the employee. Everything you do not tick is treated as a measured value. Those unticked columns are unpivoted: each heading becomes a row in the name column, and the cell value goes into the value column. The identifying columns are repeated on every resulting row so the data stays linked.

Naming the new columns

The Call the name column field sets what the heading column is called in the output. It defaults to name. If your column headings are months, you might change this to month. If they are survey questions, you might call it question. The label has no effect on the data, but a good name makes the output self-describing.

The Call the value column field does the same for the value side. It defaults to value. Change it to revenue, score, count, or whatever describes the numbers in the unpivoted columns. Downstream tools will use these names as axis labels and group headers, so a moment spent here saves confusion later.

A worked example: quarterly sales by region

Suppose you have a CSV with five columns: Region, Q1, Q2, Q3 and Q4. There are three regions: North, South, and West. Each cell holds a sales total. That gives you three rows and five columns in wide format.

Paste the CSV. In the column picker, tick Region. Leave Q1 through Q4 unticked. Set Call the name column to quarter and Call the value column to sales. The output has twelve rows. Each row has three fields: Region, quarter, and sales. North appears four times, once for each quarter. The data is now in the shape that a chart library needs to draw a grouped bar chart or that a SQL query can group by quarter.

The row count is a useful check. Three regions times four quarters should produce twelve rows. If you see a different number, you have ticked a column that should be a measurement, or left one unticked that should be an identifier.

Going from long to wide

Switch the Direction dropdown to Long to wide. Now the tool does the opposite: it reads a name column and a value column and builds one column per distinct name. The identifying columns form the row keys. The result is a compact grid that is easier for people to read.

This direction is where collisions happen. If two rows in the long data share the same identifying columns and the same name, both want the same cell in the wide table. Most tools pick one and discard the other without telling you, which means a row total at the bottom of your report is wrong by an amount you cannot trace. This tool reports the number of collisions and lets you choose what to do about them.

Handling collisions when casting to wide

The If two rows land in the same cell dropdown offers six options. Keep the first uses the earlier row and drops the later one. Keep the last does the reverse. Add them up sums the values, which makes sense when the duplicates represent parts of a total. Average them takes the mean. Count them writes how many rows collided rather than any of their values. Join them with a semicolon concatenates the values as text, which preserves everything at the cost of producing a cell that is no longer a single number.

If you are getting collisions and did not expect them, the data probably has a duplicate you did not know about. Check the input for rows where the identifying columns are identical. Adding another column to the identifying set may resolve the collision by making each combination unique.

Blank cells and the row count check

The Leave out rows with an empty value checkbox is on by default. Wide tables are usually sparse: a product launched in March has no values for January and February, and those empty cells would become rows that say nothing. Dropping them keeps the long output clean and shorter. Turn this off if the blanks carry meaning, such as a survey answer that was deliberately left empty.

Always check the row count after a reshape. For a wide-to-long conversion, the expected count is the number of original rows times the number of unticked columns, minus any blanks that were dropped. If the count is off, review which columns are ticked. A common mistake is to tick a data column by accident, which creates a much smaller output because those values become part of the identifier rather than being unpivoted.

Practical patterns for reshaping survey and financial data

Survey data is a classic use case. A spreadsheet from a form builder gives you one column per question: Q1, Q2, Q3, and so on. Each row is a respondent. To analyse the answers in aggregate, unpivot the question columns into a long format with a question column and an answer column, ticking only the respondent identifier. Now you can count how many times each answer appears for each question, build histograms, or feed the data into a dashboard.

Financial data follows the same pattern. A budget spreadsheet with a column per month is easy for a manager to fill in, but the accounting system needs rows. Unpivot the month columns, call the name column month and the value column budget, and the output is ready to import. If actuals are in a second set of columns, unpivot those separately and stack the results, or add a type column to keep both in the same table.

Common mistakes and when to use a different tool

The biggest trap when going wide to long is ticking too many columns. Every ticked column becomes part of the row identity, so ticking a data column collapses what should be many rows into very few. Start by ticking only the obvious identifiers and check the row count against what you expect.

Going long to wide with no collision handling is the second most common problem. If the output has fewer values than you expected, collisions ate the rest. Switch the collision dropdown from Keep the first to Add them up or Join them with a semicolon to find out where the duplicates are.

This tool reshapes data. It does not filter, aggregate, or chart. If you need to group timestamped data into daily or monthly buckets, the Time Series Resampler on this site does that directly and handles gaps properly. If you need summary statistics for a column of numbers, the Statistics Calculator is a better choice. All of these tools work on your own machine and never send your data anywhere.

Help

The same numbers in the shape tools expect

Tick the columns that identify a row, the name, the region, the product, and everything left over is treated as a measurement. Each of those becomes a row of its own, with the old column heading moved into a cell beside the value. One row of twelve monthly figures comes out as twelve rows: longer to read, far easier to group.

Paste your table

It needs a header row, because those headings are what become values when the table is turned on its side.

Tick the columns that identify a row

Usually the first one or two. Those are repeated down the page; every other column becomes a name and a value.

Check the row count

Twelve month columns across a hundred rows should give twelve hundred rows back. If it does not, a column is ticked that should not be.

Go the other way when you need a report

Long data is right for charting and grouping, wide data is right for reading. Switch the direction to get a readable grid back out.

Going back to wide is where rows disappear

Turning wide into long is safe: nothing can collide, and the row count is simply the number of measurements. Coming back is the risky direction. Each row of the wide table is identified by the columns you ticked, so if two long rows share those values and the same name, they both want the same cell. Most tools quietly keep one and throw the other away, and the total at the bottom of your report is then wrong by an amount nobody can trace. Here you choose what happens instead — keep one, add them up, average them or join them — and the number of collisions is reported so you know it happened at all.

Good to know

Do this before you pivot, not after

A pivot table cannot group twelve month columns because they are twelve different fields to it. Reshape first and the month becomes one field it can group by.

Blank cells are dropped by default

A wide table is mostly gaps, and turning a gap into a row that says nothing helps nobody. Untick the option if the gaps themselves matter to you.

The heading becomes ordinary data

That is the whole trick. Once Jan is a value rather than a column name, you can sort by it, filter it and total across it like anything else.

Going back needs a full set of names

Casting long data back to wide builds one column per distinct name it finds. If your data only covers three months, you get three columns, not twelve.

Common questions

What does unpivot mean?
It means turning columns into rows. A table with a column for each month becomes a table with a month column and a value column, and many more rows.
Why do I need this before making a chart?
Most charting and grouping tools want one row per observation, with the category in a field of its own. Wide data hides the category in the column heading, where nothing can reach it.
What is the difference between this and a pivot table?
A pivot table summarises long data into a grid. This makes the long data in the first place, and can also rebuild a grid without summarising anything.
Can I keep more than one identifying column?
Yes. Tick as many as you like — region and product together, for example — and all of them are repeated on every resulting row.
Does my table leave the page?
No. It is reshaped in your browser and nothing is sent anywhere.