Sheets Tip #338: A Winning Streak! WWLWWWWDW


Brought to you by:


Hi Reader,

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

After a last bite from winter last week, it looks like spring is finally here where I live on the east coast of the US. The daffodils are growing, the box turtles are out sunning themselves on logs by the river, and temperatures are forecast in the 70s (in the 20s celcius).

Wherever you are, I hope you're enjoying the changing of the seasons.


➜ News

I.
Google launched a new Data Science Agent last week that is available through Google Colab. It's an AI tool that generates Python code specifically for data analysis and data science tasks.

Read more here >>


➜ Membership

Last week in Sheets Insiders, we had a fantastic turnout of almost 200 people for our live workshop: Unlocking the Secrets of LAMBDA Functions

Normally the replays are for members-only, but since last week's workshop was open to everyone, you're welcome to watch the replay here:

video preview

Today's tip — how to count winning streaks — was one of the examples we shared in last week's workshop.

Check it out below our sponsor message.


Brought to you by: SheetWhiz

The Tool Top Tech Professionals Use For Data Analysis in Google Sheets

SheetWhiz is a Chrome extension that brings powerful Excel functionality to Google Sheets. Over 10,000 professionals at companies like Salesforce, DoorDash, Robinhood, and Databricks use SheetWhiz to work faster, stay accurate, and reclaim their productivity.

Key Features:

  • Trace Precedents & Dependents: Know your analysis inside and out.
  • Excel Shortcuts: Insert rows, auto-fit column width, paste special and more!
  • Format Cycling: Apply custom formats to numbers with a single shortcut (similar to Macabacus).
  • Export Cell Selections as Images: Paste linked screenshots of your data in Slides.

And yes – we work on a Mac!


➜ Sheets Tip #338: Win Streak Formula

Those of you who've read this newsletter for a while will know that I'm a fan of Liverpool Football Club. They play football (or soccer for my US friends) in the English Premier League and are currently enjoying a fantastic season, sitting top of the league. Go Reds!

Their win/draw/loss record for the season so far is:

WWWLWWWWDWWWWDDWWWDWWWWDWWW

Looking good!

Today, let's create a formula that counts the longest winning streak, i.e. the maximum number of consecutive "W".

First, let's split that win streak out into separate cells, and transpose to a column view with this formula:

=ArrayFormula(MID(A1, SEQUENCE(LEN(A1)), 1))

Our data looks like this:

Next, we use a SCAN function — which is a LAMBDA helper function — to add a count for each "W".

Enter this formula in cell B4:

=SCAN(0,A4:A30,LAMBDA(a,c,IF(c="W",a+1,0)))

How does this formula work?

We give the SCAN function a start value (0) and then add 1 to it every time there is a "W" in that row. If there is not a "W", it resets to 0 and starts the "W" count over again.

Finally, we use this simple MAX function to find the longest win streak:

=MAX(B4:B30)

which looks like this in our Sheet:

And if you're a formula fiend, feel free to combine them all into a single formula:

=ArrayFormula(MAX(SCAN(0,MID(A1, SEQUENCE(LEN(A1)), 1),LAMBDA(a,c,IF(c="W",a+1,0)))))

For more LAMBDA resources, check out this resource.


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

Have a great week!

Cheers,
Ben

P.S. Oh good, it's not just me then

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 #359, your Monday morning espresso, in spreadsheet form! Have you noticed how much Google Sheets has changed in the past couple of years? We tend to think of spreadsheets as static tools, but that's just not the case. When I open a Sheet today I invariably use Tables and AI tools, both of which weren't available a few years ago. So I’ve been building something new to help you get fully up to speed with the modern way...

Brought to you by: Hi Reader, Welcome to the Google Sheets Tips newsletter #358, your Monday morning espresso, in spreadsheet form! Today's tip comes from an accidental discovery I made whilst researching a trick with the LEFT and RIGHT functions. Let me ask you... What do you think happens with this formula? (Answer before trying it in your Sheet ;) ) = "A" < "B" Answer #VALUE! error TRUE #NUM! error Check out the answer in today's tip and see a real-world application below. ➜ News I.Google...

Brought to you by: Hi Reader, Welcome to the Google Sheets Tips newsletter #357, your Monday morning espresso, in spreadsheet form! Coming to your inbox on a Tuesday because it was a public holiday here in the US yesterday (Happy Labor Day!). I had a friend and his family visit (Mr Data School himself!). We had a great weekend exploring in the woods, watching the kids catch crayfish, and making s'mores over a fire in the evening. I feel recharged (and a little tired) and ready to dive into...