Sheets Tip 354: Pivot or Unpivot? How to go from tall to wide data and back again


Brought to you by:


Hi Reader,

Welcome to the Google Sheets Tips newsletter #354, your Monday morning espresso, in spreadsheet form!

In last week's newsletter we compared wide and tall data, and what the pros and cons of each data "shape" were.

Today, I want to show you how to move from one format to the other. How to transform tall data into wide data and vice versa.

Going in one direction is easy. Going back, in the other direction, is less so.

Find out which way round below!


➜ News

I.

It's that time of year when this newsletter takes a summer break!

I'll be back with issue 355 on the 18th August 2025. 🌞

II.

More details about the AI function in Google Sheets, including examples of more use cases.

Read more here >>

III.

Read/write support for Smart Chips in Google Sheets is now available with the Sheets API. This is welcome news for Apps Script developers!

Read more here >>


Brought to you by: BudgetSheet

Track & Analyze Your Spending With BudgetSheet

Automate the most tedious part of tracking your spending and preparing for taxes.

BudgetSheet can automatically categorize and import all your bank transactions and track account balances in Google Sheets. No more manual copying & pasting from CSV exports for bank data! It's quick, secure, and free to try. Join over 15,000 satisfied users today!


➜ Sheets Tip #354: Turning Tall Data Into Wide Data And Vice Versa

We saw last week that tall data is good for analysis and pivot tables, because the data is in columns.

However, wide data is easy to read and good for charts because the data is in a 2-D grid, separated into series.

Here's a quick reminder of what these tables look like:

Now let's see how to move from one format to the other, and back again.

Let's start with the easier transformation.

Turning Tall Data Into Wide Data (easy)

This is the easier transformation of the two, because pivot tables work well with tall data.

Select a cell inside a tall dataset or table and go to the menu: Insert > Pivot table

Then we can create a 2-D wide dataset by selecting a column for the rows and a column for the column headings.

In our example, it looks like this:

Turning Wide Data into Tall Data (hard)

This is harder, but possible with formulas. It's sometimes called an unpivot.

Suppose we have a dataset in A1:E9.

Enter this formula in a blank cell:

=ArrayFormula(A2:A9&"🔵"&B1:E1&"🔵"&B2:E9)

(You can pick any emoji or symbol to separate the range references!)

This combines the headers, row labels and values in a grid:

Next, we use the TOCOL or FLATTEN functions to stack these vertically:

=ArrayFormula(TOCOL(A2:A9&"🔵"&B1:E1&"🔵"&B2:E9))

which looks like this in our Sheet:

Finally, we split the rows into columns with the handy SPLIT function with the emoji as the delimiter:

=ArrayFormula( SPLIT( TOCOL( A2:A9 & "🔵" & B1:E1 & "🔵" & B2:E9 ) , "🔵"))

This puts our data into the correct tall format:

You can manually add the headings: Product, Region, Value

It's more difficult than creating the pivot table, but not too bad if you build the formula in steps (what I call the "Onion Framework").

With the knowledge from last week and today's newsletter, you'll know which data shape to use for pivot tables or charts. And how to get to it if you don't have it yet.

Never get stuck again!

Template

Grab the template here >>

Click on "Use Template" in the top right corner to make your own copy.


If you enjoyed this newsletter, please forward it to a friend who might enjoy it.

Have a great week!

Cheers,
Ben

P.S. Stop taking bad photos and enjoy the moment

Google Sheets Tips

Get better at working with Google Sheets! Join 50,000 readers to get an actionable tip in your inbox every Monday.

Read more from Google Sheets Tips

Brought to you by: Hi Reader, Welcome to the Google Sheets Tips newsletter #353, your Monday morning espresso, in spreadsheet form! Today we're looking at the shape of data. It's foundational concept that underpins pivot tables and charts in Google Sheets. Once you understand the difference between wide data (for charts) and tall data (for pivot tables), you'll be off to the races! This week is all about the pros and cons of each data shape. Next week, I'll show you how to use formulas and...

video preview

Brought to you by: Hi Reader, Welcome to the Google Sheets Tips newsletter #352, your Monday morning espresso, in spreadsheet form! If you're a parent, then you've undoubtedly watched a lifetime's worth of Disney movies. You can appreciate the genius storytelling, rich characters and beautiful visuals. (But I'm sure you'd also be content to watch a film once, not 10 times!) Anyway, there's a scene in the Disney film Ratatouille where Remy bites into a strawberry and a piece of cheese at the...

CHOOSECOLS with negative column numbers

Brought to you by: Hi Reader, Welcome to the Google Sheets Tips newsletter #351, your Monday morning espresso, in spreadsheet form! Thankfully, I'm fully recovered from the pneumonia I had last month. Sadly, we had to cancel our trip to Europe to see my family. But, the silver lining was an unexpected week at home with no agenda. So we stained the back deck, cleared out the garage, and built some raised beds in the garden. My younger self would have spent the week wallowing, annoyed at the...