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 #344, your Monday Tuesday* morning espresso, in spreadsheet form! * coming to your inbox on a Tuesday because many folks have a long weekend for Easter. In today's reader-inspired example, we're going to look at a common, but tricky, conditional formatting example: How to highlight values in one range based on activity in a different range? Today we'll look at how to create a conditional formatting rule to highlight...
Brought to you by: Hi Reader, Welcome to the Google Sheets Tips newsletter #343, your Monday morning espresso, in spreadsheet form. Thanks for all the well wishes I received to last week's email! I'm two weeks into the recovery from sinus surgery and things are slowly but surely returning to (a new) normal. I'm taking daily walks around my neighborhood, going slightly further each day. For the first couple of days I needed my wife as a support to hold on to, as I shuffled up and down the...
Brought to you by: Hi Reader, Welcome to the Google Sheets Tips newsletter #342, your Monday morning espresso, in spreadsheet form! Whew, it's been quite the week in my household. Last week I had sinus surgery to alleviate some long-standing sinus issues I've had. It was a nearly 6-hour surgery so I was completely out-of-it for a day or two afterwards. When I came round they asked if I wanted a drink. I said "some water" but I couldn't speak clearly because of the bandages etc. The nurse...