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