The Google Sheets IF function checks whether a condition is true and returns one value if it is, or another value if it is false. Enter an IF formula in a cell beginning with an equals sign; for example, with a score in B2, =IF(B2>=70,"Pass","Review") displays Pass for a score of 70 or higher and Review otherwise.
What the IF function does
People sometimes call IF a Google Sheets “command,” but it is a spreadsheet function used inside a formula. It lets a sheet make a simple decision based on the contents of cells. Rather than inspecting each row manually, you can define a rule once and apply it to many rows.
For example, a teacher could label scores as passing or needing review, a shop could mark an order as shipped or pending, and a household budget could flag expenses that exceed a chosen limit. IF does not change the value being tested; it returns a result based on the test. The result might be text, a number, a date, another calculation, or a blank-looking empty string.
In the example above, the test is whether B2 is at least 70. The two outcomes are text values, so they are enclosed in straight double quotation marks. If the test is true, Sheets returns the first outcome; if false, it returns the second.
Syntax and how the arguments work
The IF function takes a logical test, a value to return when that test is true, and an optional value to return when it is false. The arguments are separated by commas in the examples here. A logical test is an expression that Sheets can evaluate as TRUE or FALSE, such as whether one cell is greater than another or whether a cell contains a particular word.
- Logical test: The condition to check, such as whether a number is at least a threshold.
- Value if true: The result returned when the test is true. This can be text, a number, a cell reference, or another formula.
- Value if false: The result returned when the test is false. This argument is optional, but including it makes the outcome explicit.
Text results need quotation marks; cell references and numbers do not. For instance, a result that refers to cell C2 should be written as a cell reference, not as text in quotation marks. If the optional false result is omitted, Sheets returns FALSE when the test is false. In many practical sheets, it is clearer to provide a deliberate alternative such as “No,” 0, or an empty string.
Formulas in Google Sheets generally use commas between arguments in the US-style examples shown here. Depending on the spreadsheet’s locale, Sheets may require semicolons instead. If a formula copied from a guide is rejected despite otherwise correct syntax, check the spreadsheet’s locale and use the separator expected there.
Basic IF examples for everyday sheets
Start with one condition and two outcomes. Suppose column B contains test scores and a score of 70 is the passing threshold. With the score in B2, =IF(B2>=70,"Pass","Review") returns Pass for 70, 85, or 100, and Review for 69 or less. The comparison operator matters: greater than or equal to includes the threshold itself, while a greater-than test would not.
IF can also return a number. If cell C2 contains an order total, then with the total in C2, =IF(C2>=50,0,5) returns 0 when the order is at least 50 and 5 when it is lower. That might represent a simple shipping-fee rule, but a real business policy could have additional exceptions that need their own conditions.
To avoid showing a result on rows that have not been filled in, test for a blank input first. If A2 is the item name and B2 and C2 contain quantity and unit price, =IF(A2="","",B2*C2) leaves the result blank when A2 is empty and otherwise multiplies quantity by price. The empty string inside quotation marks displays as blank, although the cell still contains a formula. This is useful in a prepared table, but make sure the chosen input cell is a reliable sign that the row is complete.
To use a formula for more rows, enter it in the first result row and copy or fill it down. Relative references such as B2 usually adjust to B3, B4, and so on as the formula is filled. If a condition should always refer to one fixed cell, use an absolute reference with dollar signs, such as $F$1, so it does not shift when copied.
Testing multiple conditions
For rules that require more than one condition, combine IF with AND or OR. AND is true only when all the listed tests are true. OR is true when at least one test is true. This keeps a formula easier to understand than repeatedly nesting IF for a simple combination.
For example, suppose B2 contains a score and C2 contains a text response indicating whether required work was submitted. If eligibility requires a score of at least 70 and the response Yes, then with the score in B2 and submission status in C2, =IF(AND(B2>=70,C2="Yes"),"Eligible","Not eligible") returns Eligible only when both tests pass.
If either of two conditions is enough, use OR instead. Suppose a customer qualifies for a discount if they are a member or their order is at least 100. With membership status in B2 and order value in C2, =IF(OR(B2="Yes",C2>=100),"Discount","Standard price") returns Discount if either test is true. Make sure the cells contain the values your test expects; “yes,” “Yes,” and a checkbox value are not necessarily interchangeable in every setup.
For several different outcomes, you can nest IF functions or use IFS. A nested IF places another IF in an outcome position, so the order of tests determines which rule is considered first. With a score in B2, =IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","Below C"))) assigns the highest applicable band. Put higher thresholds first so that a score of 95 is not captured by a lower threshold before the top band is checked.
IFS is an alternative when there are several condition-and-result pairs. With the score in B2, =IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"Below C") checks the conditions in order and returns the result for the first true condition. The final TRUE condition acts as a catch-all; without a condition that covers the remaining cases, Sheets can return an error if none of the listed conditions is true.
Common errors and ways to fix them
Many IF problems come from a mismatch between the formula and the actual cell contents. A formula may be syntactically valid yet produce an unexpected result if a number is stored as text, a status has an extra space, or the comparison uses the wrong operator.
- Check quotation marks: Text outcomes need straight double quotation marks. Curly quotation marks copied from a word processor may cause a formula parse error.
- Check parentheses and separators: Each opening parenthesis needs a closing one, and the argument separator must match the spreadsheet’s locale.
- Check the threshold: Decide whether the boundary should count. Use a greater-than-or-equal comparison when a value exactly at the cutoff should qualify.
- Check blank cells: A blank may behave differently from a zero or a cell containing a formula that returns an empty string. Choose a test that matches how the data is entered.
- Check text consistency: Standardize labels such as Yes and No, and watch for accidental spaces or different spellings.
A formula parse error usually means Sheets cannot read the formula’s structure, so inspect quotes, parentheses, and separators first. A formula that returns a result but labels a row incorrectly more often points to the condition, the input data, or the order of nested tests. Try the logical test on its own in a spare cell if you need to see whether it evaluates as true or false.
IF compared with related functions
IF is a good choice when one test leads to two outcomes. For several clearly defined alternatives, IFS can make the logic more readable. For a rule that depends on multiple conditions being met together or at least one condition being met, AND and OR can be used inside IF, as shown above.
IF is not the same as conditional formatting. An IF formula writes a result into a cell; conditional formatting changes how a cell looks when a rule is met. In the Google Sheets browser, conditional formatting is available through Format > Conditional formatting. Use it to color a low score, for example, when you want a visual warning but do not need a separate text label. You can use both approaches in the same sheet.
IF is also different from functions that count or summarize matching records. If the aim is to count how many rows meet a condition, a counting function may fit better than returning a label in every row. Pick the tool based on the output you need: a decision result, a visual highlight, or an aggregate such as a count.
Excel also has an IF function with broadly similar behavior, so a simple IF formula is often familiar to people moving between the two spreadsheet programs. However, interface steps and some features differ. This article’s menu path and instructions are for Google Sheets in a web browser, not Excel’s ribbon.
Making IF formulas easier to maintain
Before adding more nested conditions, write down the rule in plain language. Identify each possible input, the result expected for it, and what should happen when data is missing or outside the usual range. This helps expose gaps, such as a grading formula that handles scores above 70 but has no intentional result for blanks.
For a small rule, it can be useful to keep the threshold in a separate cell instead of typing it into every formula. Then changing the threshold only requires editing that cell. With the threshold stored in F1 and the score in B2, =IF(B2>=$F$1,"Pass","Review") compares the score with the fixed threshold as the formula is copied down. The dollar signs keep F1 fixed while the score reference adjusts by row.
Use meaningful outcomes and avoid making a formula more complex than the task requires. A long chain of nested tests can be difficult to audit, particularly when several people edit the sheet. If the rules expand, consider documenting the thresholds beside the data or laying them out in a small lookup table. Test the formula against boundary cases and unusual inputs before relying on it across a large range.
Frequently Asked Questions
What does IF mean in Google Sheets?
IF is a function that tests a condition and returns one result when it is true and another when it is false. It is a function used in a cell formula, rather than a separate command or menu action.
How do I write an IF formula in Google Sheets?
Start the cell entry with an equals sign, then provide a condition, the true result, and the false result, separated by the correct argument separator for your locale. Text results go in quotation marks; numbers and cell references normally do not.
Can an IF formula return a blank?
Yes. Use an empty string as the result for the outcome that should appear blank. The cell still has a formula, so it is not the same as a truly empty cell for every calculation or check.
How do I use more than one condition?
Use AND inside IF when all conditions must be true, or OR when any one condition is enough. For several different outcomes, use a carefully ordered nested IF or the IFS function, and include a result for cases that do not meet earlier tests.
Why is my Google Sheets IF formula showing an error?
Check for unmatched parentheses, quotation marks that are not straight, or commas where your locale expects semicolons. If the formula runs but gives the wrong answer, verify the cell values, the comparison operator, and the order of conditions.
Related
- Inserting a Line in Word: Rules, Borders, and Shapes
- Hanging Indent in Word: How to Insert and Adjust
- Cover Page in Word: How to Insert, Edit, and Remove It
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Outlook Desktop Auto Forward: Setup and TipsTo set up auto-forwarding in Outlook desktop, create an incoming-message rule in classic Outlook for Windows: go to…
- Block a Sender in Outlook Permanently: What Actually WorksTo block a sender in Outlook and keep the block in place, add the sender’s email address to…
- How to Delete a Blank Last Page in Microsoft Word QuicklyTo delete a blank last page in Word, show formatting marks with Home > Paragraph > Show/Hide ¶,…
- Excel Page Break Preview Without Page Numbers: What to KnowIn Excel for Microsoft 365 on Windows, you cannot hide the large page-number labels while staying in Page…
- Unable to Add a Shared Mailbox in Outlook? FixesIf you cannot add a shared mailbox in Outlook, first confirm that your work or school account has…
- Print Freeze Panes in Excel: Repeat Rows on Every PageTo print frozen rows or columns on every page in Excel, use Page Layout > Print Titles and…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.