Sheets Tip 348: An elegant formula to get every combination from two lists


Brought to you by:


Hi Reader,

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

Every year I support my sister-in-law's fundraiser for Takoma Elementary School by donating a bundle of all my courses.

The full retail price is $999 and at the time of sending this email the current bid is $250.

It's a great opportunity to grab all my courses for a reduced price and support a good cause.

​Place your bid here!​


➜ News

I.
Gemini in Google Sheets
just got a big upgrade. It can now modify elements of your Sheet to create Pivot Tables, add dropdowns, apply conditional formatting etc.

I've had a quick look and it's a big step forward.

Read more here >>

II.
Google Workspace apps for Gmail, Google Drive, Google Docs, Calendar, Keep, and Tasks are now generally available for the Gemini app

Read more here >>


➜ Membership

I'm working hard behind the scenes to move the membership to a bigger, better platform, where the content and community can really shine.

Over the coming months, I'll be improving the membership by adding learning pathways and a Q&A forum.

We've also seen some killer demos recently in the membership.

Last week, we looked at using the new AI function, Gemini, and Apps Script to create an automated feedback tool for teachers.

Starting with educational data, this AI tool turns student exam scores into draft email responses in Gmail, ready to send. A massive time saver!

Join today to get access to these exclusive tutorials, live workshops, full archives and much more.

Check out Sheets Insiders here


Brought to you by: Bricks

Bricks AI Spreadsheet: Create Dashboards & Reports in 1-Click

Bricks makes creating reports and dashboards from your spreadsheet data a breeze. Just import your data and Bricks creates interactive dashboards for you in seconds - complete with charts, KPIs, insights, and tables you can customize and share.

  • Get Instant Insights: Bricks analyzes your data, surfacing patterns, trends, and key insights
  • Generate AI-Powered Summaries and Tables: Bricks organizes and summarizes your data, complete with neatly formatted tables
  • Automatically Create Charts: Bricks builds charts for you and updates them when your spreadsheet data changes

Join 10,000+ professionals from organizations like Amazon, Nvidia, and Stanford who use Bricks to get their reporting done 10x faster.


➜ Sheets Tip #348:

In this tip, we look at an elegant formula that generates all possible pairings from two lists. In technical lingo, this is called a crossjoin.

One obvious application of this is for SEO work, generating lists of keywords to focus on.

Suppose we have our first list in column A and our second list in column B. Row one is a header row.

Step 1

Use the TRANSPOSE function to turn list 2 into a row format:

=TRANSPOSE(B2:B4)

which looks like this in our Sheet:

Step 2

Use an Array Formula to combine all variations of list 1 and 2:

=ArrayFormula(A2:A5&" "&TRANSPOSE(B2:B4))

The &" " adds a space between the two words.

The output is an array of all possible combinations (called a crossjoin):

Step 3

Wrap this with TOCOL to convert the array into a single column:

=ArrayFormula(TOCOL(A2:A5&" "&TRANSPOSE(B2:B4)))

which looks like this in our Sheet:

Step 4

Sort the data with the SORT function.

SORT also has the nice property of being an array formula by design, so we can drop the ArrayFormula syntax to make our formula cleaner:

=SORT(TOCOL(A2:A5&" "&TRANSPOSE(B2:B4)))

This gives us the list of all possible combinations:

Nice!


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

Have a great week!

Cheers,
Ben

P.S. Ever wondered what would happen if you swam in a nuclear storage pool? Well, now you know.

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 #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...

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...