The most common spreadsheet formulas in Google Sheets are SUM, AVERAGE, IF, VLOOKUP, and QUERY—but the real power comes from knowing how to combine them for your specific task. This guide explains how formulas work in Google Sheets, how to write them correctly, and how to troubleshoot errors.
How Google Sheets Formulas Work
A formula in Google Sheets always starts with an equals sign (=) and can contain numbers, cell references (like A1 or B2:B10), operators (like +, -, *, /), and functions. Functions are predefined formulas that perform calculations—for example, =SUM(A1:A10) adds all numbers in cells A1 through A10.
When you type a formula, Google Sheets calculates the result and displays it in the cell. If you change any referenced cell, the formula recalculates automatically. This is the core of spreadsheet automation.
Here are a few essential functions every user should know:
=SUM(A1:A10)– adds up all numbers in the range.=AVERAGE(B1:B10)– returns the mean of the numbers.=IF(C1>100, "High", "Low")– returns “High” if C1 is greater than 100, otherwise “Low”.=VLOOKUP(D1, A1:B10, 2, FALSE)– searches for D1 in the first column of A1:B10 and returns the matching value from the second column.=QUERY(A1:D10, "SELECT A, SUM(B) GROUP BY A")– runs a SQL-like query on your data.
Writing Your First Formula: Step-by-Step
Let’s walk through creating a simple formula that calculates total sales. Assume you have sales amounts in cells B2 through B10.
- Click on the cell where you want the total (e.g., B11).
- Type
=SUM(B2:B10)and press Enter. - The cell shows the sum, and the formula bar displays the formula.
You can also use the Functions menu (Insert > Function) to browse and insert functions. For more complex formulas, use the fx button next to the formula bar to open the function help panel.
Remember: always use straight quotes (” “) for text in formulas, and separate arguments with commas (not semicolons, unless your regional settings use semicolons).
Common Formula Errors and How to Fix Them
Errors are inevitable when learning formulas. Here are the most common ones and their fixes:
#DIV/0!– You tried to divide by zero or an empty cell. Check the divisor.#N/A– A lookup function (like VLOOKUP) didn’t find a match. Use IFERROR to handle it gracefully:=IFERROR(VLOOKUP(...), "Not found").#REF!– A cell reference is invalid, often because you deleted a row or column. Undo or fix the reference.#VALUE!– The formula expects a number but got text. Ensure all referenced cells contain numeric values.#NAME?– You misspelled a function name or used a name that doesn’t exist. Check spelling.
To debug, click on the cell with the error and look at the formula bar. Google Sheets also provides a Formula evaluation tool (under Tools > Formula evaluation) that steps through calculations.
VLOOKUP vs. INDEX/MATCH vs. XLOOKUP
VLOOKUP is the most popular lookup function, but it has limitations: it can only look to the right, and it breaks if you insert columns. INDEX/MATCH is more flexible, and XLOOKUP (available in newer versions) is the modern replacement.
Here’s a quick comparison:
- VLOOKUP:
=VLOOKUP(search_key, range, index, [is_sorted]). Works only when the search column is the first column of the range. - INDEX/MATCH:
=INDEX(return_range, MATCH(search_key, search_range, 0)). Allows you to search any column and return any column. - XLOOKUP:
=XLOOKUP(search_key, search_range, return_range, [if_not_found]). Simpler and more powerful, but only available in Google Sheets (and Excel 2021+).
Example: To find the price of a product in A2:A10 with prices in B2:B10, you can use =VLOOKUP("Widget", A2:B10, 2, FALSE) or =INDEX(B2:B10, MATCH("Widget", A2:A10, 0)).
Using QUERY for Advanced Data Analysis
QUERY is Google Sheets’ most powerful function—it lets you run SQL-like queries on your data. For example, to sum sales by product category, you could use:
Assuming data in columns A (category) and B (sales), the formula =QUERY(A1:B100, "SELECT A, SUM(B) GROUP BY A LABEL SUM(B) 'Total'") returns a table with categories and their totals.
QUERY supports WHERE, ORDER BY, GROUP BY, and even PIVOT. It’s ideal for creating dynamic reports without pivot tables. However, it has a learning curve—start with simple SELECT statements and gradually add clauses.
Array Formulas and Dynamic Ranges
Array formulas perform multiple calculations on one or more ranges and return multiple results. In Google Sheets, you can use ARRAYFORMULA to apply a function to an entire column. For example, =ARRAYFORMULA(C2:C10*D2:D10) multiplies each pair of cells in columns C and D.
Another way is to use functions that natively handle arrays, like SUMIF or FILTER. For instance, =FILTER(A2:A100, B2:B100 > 100) returns all values in column A where the corresponding B cell is greater than 100.
Array formulas are powerful but can slow down large sheets. Use them judiciously.
Formula Best Practices and Performance
To keep your spreadsheet fast and avoid errors:
- Use absolute references (like
$A$1) when copying formulas to prevent references from shifting. - Keep ranges as small as possible—don’t reference entire columns (e.g.,
A:A) unless necessary. - Use
IFERRORto handle expected errors. - Document complex formulas with comments (Insert > Comment).
- Avoid volatile functions like
NOW()andRAND()in large sheets because they recalculate constantly.
For performance, consider using pivot tables for aggregations instead of array formulas, especially with thousands of rows.
Frequently Asked Questions
How do I copy a formula down a column without changing references?
Use absolute references (e.g., $A$1) to lock specific cells. For example, =B2*$C$1 will always multiply by C1 when copied down.
Why does my formula show the text instead of the result?
Check that the cell is not formatted as text. Go to Format > Number > Automatic. Also, ensure the formula starts with an equals sign and has no leading apostrophe.
Can I use Excel formulas in Google Sheets?
Most basic formulas work identically, but some advanced functions (like XLOOKUP) have different syntax or names. Google Sheets also has unique functions like QUERY and SPLIT that Excel lacks.
How do I combine text and numbers in one formula?
Use the ampersand (&) or the CONCATENATE function. For example, ="Total: " & SUM(A1:A10).
What is the difference between a formula and a function?
A formula is any expression that starts with =, like =A1+B1. A function is a predefined formula, like SUM or IF. Functions are used within formulas.
How do I troubleshoot a formula that returns an unexpected value?
Use the Formula evaluation tool (Tools > Formula evaluation) to step through calculations. Also, check for hidden characters or spaces in referenced cells.
Related
- Google Sheets Budget Spreadsheet: Setup and Formulas
- Finance Spreadsheet in Google Sheets: Setup and Formulas
- Budget Spreadsheet in Google Sheets: Setup and Tips
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Analysis Tab in Excel: Where It Is and What It DoesExcel does not have one permanent ribbon tab simply called “Analysis.” If you mean the PivotTable Analyze tab,…
- Protect Range Not Showing in Google Sheets? Try These FixesIf Protect sheets and ranges is missing in Google Sheets, first check that you have editor access and…
- Google Sheets QUERY Clause GuideThe QUERY function in Google Sheets is a powerful tool that lets you run SQL-like queries on your…
- Calculate Age in Excel From Two Dates: Exact YearsTo calculate someone’s age in completed years from a birth date and a second date, enter the birth…
- Show Unread Emails in Outlook and Keep Them VisibleTo show only unread emails in Outlook, open the inbox or folder you want to check and apply…
- Can You Merge Cells in Google Sheets? How It WorksYes, you can merge cells in Google Sheets in a web browser. Select the cells, then choose Format…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.