A Complete Guide to Google Sheets Formulas for Work and Interviews
Mastering Google Sheets: 15 Advanced Formulas Every Data Analyst Must Know (With Real Examples)
Table of Contents
- SUMIF / SUMIFS
- COUNTIF / COUNTIFS
- VLOOKUP / XLOOKUP
- INDEX + MATCH
- FILTER
- QUERY
- ARRAYFORMULA
- TEXT & DATE Functions
- IF / IFS / SWITCH
- Text Functions
- UNIQUE / SORT / SORTN
- IS Functions
- IFERROR
- REGEX Functions
- SPARKLINE
1. SUMIF / SUMIFS – Conditional Totals
When to use: Use SUMIF
when you want to add up numbers in one range based on a single condition applied to another range. Use SUMIFS
when you have multiple conditions to meet.
Example: If you want to calculate the total sales where the region is "East", you can use:
=SUMIF(B:B, "East", A:A)
This sums all values in column A only when the corresponding value in column B is "East".
Example with multiple conditions: To sum sales where the region is "East" and the product is "TV", use:
=SUMIFS(A:A, B:B, "East", C:C, "TV")
This adds values in column A where column B is "East" and column C is "TV".
2. COUNTIF / COUNTIFS – Count With Conditions
When to use: Use COUNTIF
to count how many cells meet a single criterion. Use COUNTIFS
to count how many rows meet multiple criteria.
Example: To count how many sales values are greater than 500:
=COUNTIF(B:B, ">500")
This counts all cells in column B where the value is greater than 500.
Multiple criteria example: To count rows where the region is "West" and sales are greater than 1000:
=COUNTIFS(B:B, "West", C:C, ">1000")
This counts rows that satisfy both conditions simultaneously.
3. VLOOKUP / XLOOKUP – Vertical Data Lookup
When to use: Use VLOOKUP
to find a value in the first column of a range and return a value from a specified column in the same row. XLOOKUP
is a more flexible and modern alternative.
Example: To find the price of "Product A" in a list:
=VLOOKUP("Product A", A2:B10, 2, FALSE)
This looks for "Product A" in the first column of the range A2:B10 and returns the corresponding price from the second column.
Using XLOOKUP:
=XLOOKUP("Product A", A2:A10, B2:B10, "Not Found")
This searches for "Product A" in the range A2:A10 and returns the corresponding value from B2:B10. If not found, it returns "Not Found".
4. INDEX + MATCH – More Flexible Lookup
When to use: Use INDEX + MATCH
when you want a more flexible alternative to VLOOKUP
, such as looking up values to the left or dynamically specifying the return column.
Example: To return a value from column C that corresponds to "Product A" in column A:
=INDEX(C2:C10, MATCH("Product A", A2:A10, 0))
MATCH
finds the row number of "Product A" and INDEX
returns the value from column C in that row.
5. FILTER – Dynamic Row Filtering
When to use: Use FILTER
to extract rows from a dataset that meet certain conditions, dynamically updating as the data changes.
Example: To get all rows where sales are greater than 1000:
=FILTER(A2:C100, C2:C100 > 1000)
This returns all rows from columns A to C where the value in column C exceeds 1000.
6. QUERY – SQL-Like Data Analysis
When to use: Use QUERY
to perform powerful, SQL-style data manipulations within Google Sheets, such as grouping, filtering, and sorting.
Example: To calculate total sales per region:
=QUERY(A1:C, "SELECT B, SUM(C) GROUP BY B", 1)
This groups data by the region (column B) and sums the sales values (column C).
Filtering example: To display only rows where sales are greater than 500:
=QUERY(A1:C, "SELECT * WHERE C > 500", 1)
This shows all columns for rows where sales (column C) are greater than 500.
7. ARRAYFORMULA – Apply Formula to Whole Columns
When to use: Use ARRAYFORMULA
to apply a formula to an entire range or column, avoiding the need to drag formulas down manually.
Example: To multiply all values in column A by 10%:
=ARRAYFORMULA(A2:A * 0.1)
This applies the multiplication to every cell in the range A2 downwards.
Another example: To combine first and last names from columns A and B:
=ARRAYFORMULA(A2:A & " " & B2:B)
This concatenates corresponding cells from both columns into full names.
8. TEXT & DATE Functions
When to use: Use these functions to format dates or extract parts of dates for reporting or analysis.
=TEXT(A2, "MMMM YYYY")
– Converts a date in A2 to a readable format like "July 2025".=MONTH(A2)
– Extracts the month number from a date in A2 (1 for January, 2 for February, etc.).
9. IF / IFS / SWITCH – Conditional Logic
When to use: Use these functions to perform logical tests and return values based on conditions.
Example: To label sales as "High" if greater than 1000, otherwise "Low":
=IF(A2 > 1000, "High", "Low")
Multiple conditions example: To categorize sales into "High", "Medium", or "Low":
=IFS(A2 > 1000, "High", A2 > 500, "Medium", TRUE, "Low")
SWITCH example: To convert codes to text labels:
=SWITCH(A2, "A", "Alpha", "B", "Beta", "Unknown")
This returns "Alpha" if A2 is "A", "Beta" if "B", otherwise "Unknown".
10. Text Functions (SPLIT, LEFT, TRIM, UPPER/LOWER)
Function | Purpose | Example |
---|---|---|
SPLIT | Splits text into separate parts based on a delimiter | =SPLIT(A2, " ") |
LEFT | Extracts a specified number of characters from the start of text | =LEFT(A2, 5) |
TRIM | Removes extra spaces from text | =TRIM(A2) |
UPPER/LOWER | Converts text to uppercase or lowercase | =UPPER(A2) |
11. UNIQUE / SORT / SORTN – Organize Data
When to use: Use these to get unique values, sort data, or retrieve the top N rows.
Example: To get unique values from a list:
=UNIQUE(A2:A)
Sort data by column B in descending order:
=SORT(A2:B, 2, FALSE)
Get top 5 products by sales:
=SORTN(A2:B, 5, 0, 2, FALSE)
12. IS Functions – Data Validation Checks
Function | Description |
---|---|
ISNUMBER | Returns TRUE if the value is a number |
ISTEXT | Returns TRUE if the value is text |
ISBLANK | Returns TRUE if the cell is empty |
ISERROR | Returns TRUE if the value contains an error |
13. IFERROR – Graceful Error Handling
When to use: Use IFERROR
to prevent your sheet from showing error messages and instead display a custom message or value.
Example: To divide A2 by B2 but show "Error" if B2 is zero or empty:
=IFERROR(A2/B2, "Error")
14. REGEX Functions – Extract or Validate Text Patterns
Function | Purpose | Example |
---|---|---|
REGEXEXTRACT | Extracts matching text based on a pattern | =REGEXEXTRACT(A2, "\d+") |
REGEXREPLACE | Replaces matching text based on a pattern | =REGEXREPLACE(A2, "[0-9]", "") |
REGEXMATCH | Returns TRUE if text matches a pattern | =REGEXMATCH(A2, "invoice") |
15. SPARKLINE – Mini Chart Inside a Cell
When to use: Use SPARKLINE
to visually summarize data trends within a single cell, ideal for dashboards.
Example: To create a small line chart for sales data in columns B to F:
=SPARKLINE(B2:F2)
Final Interview Tips:
- Explain your formulas clearly and logically during interviews.
- Demonstrate advanced skills with
QUERY
andARRAYFORMULA
. - Show data cleaning and preparation using
TEXT
andREGEX
functions. - Build dynamic dashboards using
SPARKLINE
,FILTER
, andSORT
.
Want More?
If you want a free cheat sheet PDF or a mock dataset to practice these formulas, leave a comment below or email me at [your-email].
Comments
Post a Comment