|
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 #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...
Hi Reader, Welcome to the Google Sheets Tips newsletter #364, your Monday morning espresso, in spreadsheet form! Thanks to the hundreds of you who signed up for the Modern Google Sheets course last week. I'm excited to teach the workshops, which start next week. And thanks for your patience with the extra course promotion emails. We're now back to business as usual, with the once-a-week Google Sheets Tips newsletter. Lastly, Happy Halloween! It's a fun night here in our little town. Most of...
Hi Reader, Welcome to the Google Sheets Tips newsletter #363, your Monday Tuesday* morning espresso, in spreadsheet form! (* arriving in your inbox on a Tuesday, because it was Columbus Day in the US yesterday.) Almost two years ago, I launched a course called "The AI Playbook for Google Sheets", which explored how to use basic AI inside Sheets. (Fun fact: this was my last course launch!) A lot has changed since then! Today, Gemini and other AI tools can manipulate data, generate formulas,...