|
Brought to you by:
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. ➜ NewsI. ➜ MembershipLast 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: 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. ➜ Sheets Tip #338: Win Streak FormulaThose 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, |
Get better at working with Google Sheets! Join 50,000 readers to get an actionable tip in your inbox every Monday.
Brought to you by: Hi Reader, Welcome to the Google Sheets Tips newsletter #367, your Monday morning espresso, in spreadsheet form! For my birthday this year, my wife bought me a half-day fly fishing lesson. I had previously tried casting with a fly rod a few years ago in Wyoming, and have been keen to have another go ever since. As a middle-aged dad, my life is, well... maybe a little... predictable. In a good way. Family, work, exercise outdoors, eat, sleep, and repeat. It's a wonderful,...
Hi Reader, Welcome to the Google Sheets Tips newsletter #366, your Monday morning espresso, in spreadsheet form! ➜ News I.Gemini in Google Sheets can now analyze data across multiple tables. Excellent news! Read more here >> II.Google's Gemini Deep Research now integrates with your Workspace content, including Sheets. (This is only available for paid Workspace accounts.) Read more here >> ➜ Sheets Tip #366: Stack lists with the magic of TOCOL Suppose we have lists of names like this: In this...
Brought to you by: Hi Reader, Welcome to the Google Sheets Tips newsletter #365, your Monday morning espresso, in spreadsheet form! Fall is beautiful on the Eastern seaboard of the US right now. The colors near me are peaking in an explosion of reds, oranges, purples, and yellows: ➜ News I.More powerful pivot tables now available in Connected Sheets. Connected Sheets lets you use the Sheets interface to analyze BigQuery data (huge datasets with millions of rows). Read more here >> II.Google...