In this article:

How to Unpivot a Table in Google Sheets (Easiest Way in 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:


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.

Automate repetitive tasks with Lido

Save hours on repetitive and tedious work. Lido is a new spreadsheet that connects your spreadsheets, forms, PDFs, and email inbox.

Select trigger
When a cell value in Google Sheets changes
Check Google Sheets for today's date
When a new row is added to Google Sheets
On new Google Form submission
Send me a daily reminder
On new Typeform submission
When a cell value in database changes
Check database for today's date
When a new row is added in database
When a new HubSpot customer is created
Select action
Creates a one- or multiple-day calendar event with optional attendees
Adds an object to Hubspot
Create a Slack channel, and optionally add a topic or members
Makes any HTTP request
Replaces [@column_name] values in a Google Doc with the corresponding table row's values
Replaces [@column_name] values in a Google Doc with the corresponding table row's values, then export it as a PDF
Makes any HTTP request and returns the response
Inserts given array below defined values in given worksheet
Sends an email using your Google account
Sends an email using your Microsoft Outlook account
Sends a Slack message
Sends an SMS message using your Twilio account
Updates cells with given values
Updates a property of a Hubspot object
Trigger is required
Action is required
Get started