Sheets-only formulas
QUERY, FILTER, LAMBDA, MAP and BYROW on real work data.
8 articles in this department
The exact error wording in this department
-
Make your own Google Sheets function with LAMBDA and Named functions
D2 =LAMBDA(rate, hours, rate*MIN(hours, 40) + rate*1.5*MAX(hours-40, 0)) Before as you see it A B C D 1 Name Rate Hours Gross pay 2 Rachel 22 46 #N/A 3 Kevin 18.5 38 703 4 Maria 25 41 1037.5 5 James 20 32 640 6 Linda 24 44 1104 7 Carlos 19 40 760 8 Emily 21 52 1218 What changed OT_PAY saved under Data > Named functions D2:D8 now call =OT_PAY(B2, C2) and so on down After one named function A B C D 1 Name Rate Hours Gross pay 2 Rachel 22 46 1078 3 Kevin 18.5 38 70
-
LET in Google Sheets: name the piece your formula repeats
F4 =IF(VLOOKUP(E4,$A$2:$C$9,3,FALSE)>=20000, VLOOKUP(E4,$A$2:$C$9,3,FALSE)*0.05, VLOOKUP(E4,$A$2:$C$8,3,FALSE)*0.02) Before three VLOOKUPs E F 1 Rep Bonus 2 Marcus 364 3 Priya 1000 4 Maria #N/A 5 Luis 1550 6 Tom 196 What changed The lookup is written once, as sales Every use reads $A$2:$C$9 After LET E F 1 Rep Bonus 2 Marcus 364 3 Priya 1000 4 Maria 308 5 Luis 1550 6 Tom 196 Figure 1. Bonuses in F2:F6. The repeated formula fails only for Ma
-
ARRAYFORMULA down a whole column, stopping at the last row
E2 =ARRAYFORMULA(IF(A2:A="", , C2:C*15+D2:D*35)) Before =ARRAYFORMULA(C2:C*15+D2:D*35) B C D E 1 Name T-shirts Hoodies Total ($) 2 Emily 2 1 #REF! 3 Jacob 1 0 15 4 Sarah 0 2 70 5 Michael 3 1 80 6 Ashley 1 1 50 7 David 2 0 What changed E3:E cleared IF(A2:A="", , ...) added around the math After one formula in E2 B C D E 1 Name T-shirts Hoodies Total ($) 2 Emily 2 1 65 3 Jacob 1 0 15 4 Sarah 0 2 70 5 Michael 3 1 80 6 Ashley 1 1 50 7 David 2 0 30 Figure 1. Column
-
Google Sheets UNIQUE: ignore blanks, sort, combine columns
D2 =UNIQUE(A2:A) Before as you see it A D 1 Saturday Saturday names 2 Emily Emily 3 Jacob Jacob 4 Sarah Sarah 5 6 Megan Megan 7 Emily Ryan 8 Ryan Tyler What changed FILTER drops empty cells SORT puts the names A to Z After =SORT(UNIQUE(FILTER(A2:A, A2:A<>""))) A D 1 Saturday Saturday names 2 Emily Emily 3 Jacob Jacob 4 Sarah Megan 5 Ryan 6 Megan Sarah 7 Emily Tyler 8 Ryan Figure 1. Column D on the Broken and Fixed tabs. The gap at D5 co
-
Extract URL from hyperlink in Google Sheets, and link to a tab
To extract the URL from a hyperlink in Google Sheets, read the link's formula text instead of the cell. For a link in A2, =REGEXEXTRACT(FORMULATEXT(A2), "https?://[^""]+") returns the web address, filled down one row at a time. FORMULATEXT returns the HYPERLINK formula as text, and REGEXEXTRACT picks the address out of it. That only works when the link is a HYPERLINK formul
-
MAP, REDUCE and SCAN in Google Sheets: running total, test each row
E2 =SCAN(0, C2:C9, LAMBDA(total, x, total + x)) Before SUM and AND inside ARRAYFORMULA A B C D E F 1 Date Seller Amount Running total Row OK 2 Nov 3 Emily 42 225 FALSE 3 Nov 3 Jacob 35 4 Nov 4 18 5 Nov 4 Olivia 0 6 Nov 5 Michael 27 7 Nov 5 Sarah 50 8 Nov 6 David 31 9 Nov 6 Emily 22 What changed E2 SUM to SCAN F2 AND to MAP After SCAN in E2, MAP in F2 A B C D E F 1 Date Seller Amount Running total Row OK 2 Nov 3 Emily 42 42 TRUE 3 Nov 3 Jacob 35 77 TRUE 4 Nov 4 18 95 FALSE 5 Nov
-
Turn a Google Sheets table into one column (TOCOL, FLATTEN, WRAPROWS)
F2 =TOCOL(B2:D) → =TOCOL(B2:D, 1) Before =TOCOL(B2:D) A B C D F 1 Day Open Mid Close All shifts 2 Mon Dana Marcus Luis Dana 3 Tue Priya Tom Marcus 4 Wed Aisha Ken Luis 5 Thu Dana Marcus Priya 6 Fri Luis Priya Aisha 7 Tom 8 Aisha 9 Ken 10 11 12 Dana 13 Marcus 14 Luis 15 Priya 16 Aisha What changed second argument 1 added empty rows at F6, F10, F11 gone After =TOCOL(B2:D, 1) A B C D F 1 Day Open Mid Close All shifts 2 Mon Dana Marcus Luis Dana 3 Tue Priya Tom Marcus 4 Wed Aisha Ken Lui
-
Combine tabs into one list with VSTACK (and skip the blank rows)
The first tab shows at the top of the combined list, and the next tab's rows land far below it, past hundreds of empty rows. In the take-home copy, Ashley, the first name on the Oct tab, ends up in row 1001, and Chris, the first November name, is in row 2000. Above them, rows 2 to 5 hold the four September names and everything else is empty, so the stacked list looks like it stopped after one