Cheat sheet
SQL cheat sheet
SQL cheat sheet grouped by task: filter, group and count, join, NULLs, dates, CTEs and window functions. Every query runs on a real store database.
Cheat sheet · 8 tasks · 38 formulas, each run on the Excel levels’ spreadsheet engine
The formulas analysts use every week, grouped by the job you need done. Each one was checked on the same store data the Excel levels use, and each group links to the levels that teach it.
Formulas work the same in Microsoft Excel 365 and Google Sheets. They assume the layout below: order lines in A1:J41, a product list in L1:O121, two inputs in R1:R2. Type a formula in T2 (or the cell named) and fill down where it says so.
A1:J41A order_id · B order_date · C channel · D status · E product_id · F quantity · G unit_price · H discount_pct · I city · J email40 order lines from March 2025, stray spaces and blank cities included
L1:O121L product_id · M name · N category · O unit_costthe 120 products
Q1:R2R1 tax rate 8.25% · R2 price threshold 75input cells, labels in Q
=F2*G2*(1-H2/100) Relative references move as you fill: row 3 reads F3, G3, H3.
=G2*(1+$R$1) Without $, filling down turns R1 into R2, R3 …, so every row after the first reads the wrong cell. F4 cycles $R$1 → R$1 → $R1 → R1.
=$G2*R$1 $G2 keeps column G when filled right; R$1 keeps row 1 when filled down.
=G2/SUM($G$2:$G$41) =SUM(F2:F41)
=AVERAGE(G2:G41)
=MEDIAN(G2:G41) =MIN(G2:G41)
=MAX(G2:G41)
=LARGE(G2:G41,3) =COUNT(G2:G41)
=COUNTA(I2:I41)
=COUNTBLANK(I2:I41) COUNT counts numbers only; COUNTA counts anything that is not empty.
=ROUND(AVERAGE(G2:G41),2)
=ROUNDUP(F2/4,0) ROUND changes the value; a number format only changes how it looks.
=SUMPRODUCT(F2:F41,G2:G41) =IF(G2>=$R$2,"high","low") =IFS(G2<50,"under 50",G2<200,"50-199",TRUE,"200+") The final TRUE is the catch-all. Without it, a value no test matches gives #N/A.
=IF(AND(C2="web",G2>200),"review","") =IF(OR(D2="cancelled",D2="refunded"),"lost","kept") =COUNTIF(C2:C41,"web")
=COUNTIFS(C2:C41,"web",D2:D41,"completed") =SUMIFS(F2:F41,C2:C41,"app",D2:D41,"completed")
=AVERAGEIFS(G2:G41,C2:C41,"web") SUMIFS takes the column to add first, then range/criterion pairs.
=COUNTIFS(G2:G41,">=75",D2:D41,"<>cancelled") =COUNTIFS(G2:G41,">="&R2) Join the operator and the cell with &. ">=R2" would look for the text R2.
=MAXIFS(G2:G41,C2:C41,"marketplace") =COUNTIFS($C$2:$C$41,$T5,$D$2:$D$41,U$4) Channels down T5:T7, statuses across U4:V4. Type in U5 and fill right and down: $C/$D stay put, $T5 keeps the column, U$4 keeps the row.
=XLOOKUP(E2,$L$2:$L$121,$M$2:$M$121,"not found") Exact match by default; the 4th argument replaces #N/A.
=INDEX($N$2:$N$121,MATCH(E2,$L$2:$L$121,0)) The 0 in MATCH means exact match. Leave it out and you get the nearest smaller key.
=VLOOKUP(E2,$L$2:$O$121,3,FALSE) Without FALSE, VLOOKUP does an approximate match and returns wrong rows on unsorted data. It also breaks when a column is inserted.
=IFNA(INDEX($M$2:$M$121,MATCH(E2,$L$2:$L$121,0)),"missing") =TRIM(I2)
=PROPER(TRIM(I2))
=UPPER(C2) =LEFT(J2,FIND("@",J2)-1)
=MID(J2,FIND("@",J2)+1,100) =C2&" / "&D2
=TEXTJOIN(", ",TRUE,C2,D2,I2) TEXTJOIN with TRUE skips empty cells, so a missing city leaves no ", ," gap.
=SUBSTITUTE(J2,"@"," at ")
=LEN(TRIM(I2)) =VALUE("42.50")
=ISNUMBER(G2) Numbers stored as text sit left-aligned and SUM ignores them. VALUE converts.
=YEAR(B2)
=MONTH(B2)
=WEEKDAY(B2,2) WEEKDAY with 2 numbers Monday as 1 and Sunday as 7.
=TEXT(B2,"yyyy-mm") TEXT returns text, which groups and sorts well but no longer does date maths.
=EOMONTH(B2,0)
=EDATE(B2,1) =DATE(2025,12,31)-B2
=DATEDIF(B2,DATE(2025,12,31),"m") Dates are numbers (days), so subtraction gives days. DATEDIF gives whole months or years.
=COUNTIFS(B2:B41,">="&DATE(2025,1,1),B2:B41,"<"&DATE(2025,2,1)) =IF(ISBLANK(I2),"unknown",TRIM(I2)) =IFERROR(G2/F2,0) IFERROR hides every error, typos included. Use IFNA when only "not found" is expected.
=COUNTIF($J$2:$J$41,J2)>1 TRUE on every copy, the first one included.
=COUNTIF($J$2:J2,J2)=1 The range grows as you fill down, so only the first time a value appears is TRUE.
=IF(F2<=0,"check quantity","") https://analystquest.com/resources/excel-cheat-sheet/ · Free levels to practise every snippet: analystquest.com
Cheat sheet
SQL cheat sheet grouped by task: filter, group and count, join, NULLs, dates, CTEs and window functions. Every query runs on a real store database.
Cheat sheet
pandas cheat sheet grouped by task: filter rows, groupby, merge, missing values, text cleaning and dates. Every snippet runs on a real store dataset.
Interview prep
Questions from real analyst interviews, each with a model answer, the answer that loses points and a level to practise it. Terms you are unsure of are in the glossary.