In this article:

How to Unpivot a Table in Google Sheets (Easiest Way in 2024)

December 5, 2024

How to Unpivot a Table in Google Sheets

Unpivoting data in Google Sheets is a process of converting a wide format table (where data is spread across multiple columns) into a long format table (where the data is presented in rows).

If you have a simple dataset and want to unpivot it without scripting, you can use a combination of FLATTEN, SPLIT, and array formulas. This method works well for smaller datasets and requires a bit of manual setup.

Assuming you have a dataset where A1 is the top-left cell:

Step 1: Combine The Data

Determine the range of your data that you want to unpivot. Let's say your data is in A2:C4, where A2:A4 are your row identifiers, and B1:C4 are the columns you want to unpivot.

google sheets unpivot

In a new column, concatenate the row identifier with each value you want to unpivot, using a unique separator. For example, in A7, you might use:

=ArrayFormula(B1:C1&" | "&A2:A4&" | "&B2:C4)

unpivot google sheets

Step 2: Flatten The Data

To convert the combined data into a single column, wrap the previous formula with the FLATTEN function:

=ArrayFormula(FLATTEN(B1:C1&" | "&A2:A4&" | "&B2:C4))

unpivot table google sheets

This step stacks all the data into one tall, single column, as shown above. 

Step 3: Split The Data Into Columns

To finalize the unpivot process, you'll split the flattened data into separate columns:

=ArrayFormula(SPLIT(FLATTEN(B1:C1&"|"&A2:A4&"|"&B2:C4),"|"))

The SPLIT function here uses the | character to divide the combined data back into distinct columns: one for your original column headings, one for your row headings, and one for the data points.

how to unpivot a table in google sheets

And that's it! You've successfully transformed your data from a wide format to a long format using Google Sheets, without needing any special scripts or tools, just clever use of formulas.

We hope that this article has helped you and given you a better understanding of how to unpivot a table in Google Sheets. If you enjoyed this article, you might also like our articles on how to set up conditional formatting for dates within 30 days in Google Sheets and how to make a tournament bracket in Google Sheets.

Get Google Sheets productivity and automation tips delivered straight to your inbox
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
We'll email you 1-3 times a week — and never share your information.

Work less, automate more!

Use Lido to connect your spreadsheets to email, Slack, calendars, and more to automate data transfers and eliminate manual copying and pasting. View all use cases ->