In Google Sheets, IF syntax is =IF(condition, value_if_true, value_if_false): it checks a condition and returns one result when it is true and another when it is false. For example, with a score in A2, =IF(A2>=60,"Pass","Try again") displays Pass for a score of 60 or higher and Try again otherwise.
What the IF function does
IF is a logical function: it lets a spreadsheet make a choice based on a test. The condition, also called a logical expression, must resolve to TRUE or FALSE. Google Sheets then returns the second argument if the condition is TRUE, or the third argument if it is FALSE. The returned result can be text, a number, a date, a cell reference, or the result of another formula.
The general structure has three parts:
- Condition: the comparison Sheets evaluates, such as whether a cell is greater than a number.
- Value if true: what to return when the condition is TRUE.
- Value if false: what to return when the condition is FALSE. This argument is optional; if you leave it out, Sheets returns FALSE when the condition is false.
In spreadsheet formulas, text results must be enclosed in straight double quotation marks. References to cells, such as A2, do not go in quotation marks. Keep the parentheses balanced and separate the arguments with commas when your spreadsheet locale uses commas.
Basic IF examples
Assume a student’s score is in A2. This formula checks whether the score meets a passing threshold of 60 and displays one of two messages:
=IF(A2>=60,"Pass","Try again")
A score of 75 returns Pass; a score of 52 returns Try again. The comparison operator >= means “greater than or equal to,” so a score of exactly 60 passes. Change the number or the result text to match your own rule.
IF can also return a number instead of a word. Assume the quantity in A2 is the number of items ordered:
=IF(A2>=10,5,0)
This returns 5 when the quantity is at least 10 and 0 otherwise. A number returned by IF can be used in later calculations, unlike a text label that may need extra handling. The formula itself does not apply a discount or change the value in A2; it only displays its result in the cell where you enter it.
To use a value stored in a cell as the threshold, assume the score is in A2 and the passing mark is in B2:
=IF(A2>=B2,"Pass","Try again")
Referencing B2 makes the rule easier to update: changing the threshold in B2 changes the result without editing the formula. You can copy the formula down a column, and Sheets will normally adjust relative references, so the next row will compare A3 with B3.
Comparison operators and conditions
Common comparison operators in Sheets include = (equal to), <> (not equal to), > (greater than), < (less than), >= (greater than or equal to), and <= (less than or equal to). An operator is part of the condition, not a separate IF argument.
Assume a stock count is in A2. This formula flags a reorder when the count is below five:
=IF(A2<5,"Reorder","In stock")
For an equality check, assume a delivery status is in A2:
=IF(A2="Delivered","Complete","Pending")
Text comparisons are generally not case-sensitive in Google Sheets: for example, a basic equality check does not distinguish “Delivered” from “DELIVERED.” Watch for extra spaces, however; a cell containing “Delivered ” with a trailing space may not match the expected text. If the condition needs to test several possibilities, consider using a dedicated text-cleaning step or a function such as TRIM rather than making an already complicated IF formula harder to maintain.
Handling blanks and text
A blank check is a common reason to use IF. Assume A2 contains an optional email address:
=IF(A2="","Missing email","Ready")
If A2 is empty, the formula displays Missing email; otherwise, it displays Ready. This check also treats a formula that returns an empty string ("") as blank for this comparison. That can be useful in a report where other formulas leave cells visually empty, but it means the test is not limited to cells that have never contained anything.
To return an empty-looking result instead of a label, assume A2 contains a review score and the minimum acceptable score is 3:
=IF(A2>=3,"Keep","")
The final pair of quotation marks tells Sheets to return an empty string when the score is below 3. The result looks blank, but the formula remains in the cell. This distinction matters when checking whether a cell is truly empty, counting results, or using the output in another formula.
When text contains punctuation or quotation marks, make sure the text argument is enclosed correctly. To include a literal double quote inside a text result, Sheets requires the quote to be doubled within the quoted text. For ordinary labels, keeping wording simple avoids this extra escaping.
Nested IF and multiple outcomes
A nested IF places one IF inside another, allowing a formula to choose among more than two outcomes. It works, but each added layer makes the formula more difficult to read and easier to break. Assume a score is in A2 and the grading bands are 90 for A, 80 for B, and 70 for C:
=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","Below C")))
Sheets checks the conditions in order. A score of 85 fails the first test and meets the second, so the result is B. A score of 65 fails all three and returns Below C. Put the highest threshold first; otherwise, a broad condition might match before the formula reaches a more specific one.
For a longer list of exclusive conditions, IFS can be easier to scan. Assume the same score is in A2:
=IFS(A2>=90,"A",A2>=80,"B",A2>=70,"C",TRUE,"Below C")
IFS checks condition-and-result pairs from left to right and returns the result for the first TRUE condition. The final TRUE acts as a catch-all, much like the final “otherwise” result in a nested IF. Without a condition that catches remaining cases, IFS can return an error when none of its conditions is true.
Combining conditions with AND and OR
Use AND inside IF when every requirement must be true. Assume a customer’s order total is in B2 and their membership status is in C2. This formula grants a label only if the order is at least 100 and the status is Gold:
=IF(AND(B2>=100,C2="Gold"),"Eligible","Not eligible")
Use OR when at least one condition is enough. Assume a task’s priority is in B2 and its due date is in C2; the formula flags the task if it is marked Urgent or is overdue:
=IF(OR(B2="Urgent",C2<TODAY()),"Review","Normal")
TODAY() returns the current date, so the overdue test changes as days pass. A due date equal to today is not earlier than today and will not meet the date part of this condition. These examples show why it is useful to decide whether a rule requires all conditions or just one before choosing AND or OR.
Common IF errors and how to fix them
- Wrong separators: Commas work in many Sheets locales, but some locales use semicolons between arguments. If Sheets rejects a formula that otherwise looks right, check the spreadsheet’s locale in File > Settings and use the separator expected there.
- Missing quotation marks: Text results such as Pass must be written as quoted text. Without quotes, Sheets may interpret a word as a named range or report an error.
- Unbalanced parentheses: Each opening parenthesis needs a closing one. Nested IF formulas are especially easy to miscount; indenting or building the formula one layer at a time can help.
- Testing the wrong boundary:
>excludes values equal to the threshold, while>=includes them. Decide deliberately whether an exact boundary should pass. - Using an IF when no choice is needed: If the goal is to count cells matching a condition or add only qualifying values, COUNTIF or SUMIF may be more direct than making an IF result for every row.
- Confusing an empty string with a truly empty cell: A formula returning
""looks blank but is still a formula result. This can affect later tests and data summaries.
When formulas are rejected, click the cell and inspect the formula bar for missing separators, quotes, or parentheses. Google Sheets also displays an error message that can point to a parse problem or an invalid reference. Fix one issue at a time rather than rewriting a long formula all at once.
When to use IF—and when not to
IF is a good fit when one condition leads to two clear outcomes, such as showing “Late” or “On time,” assigning a simple category, or leaving a result blank until information is entered. It is also helpful when a calculation should only appear after a prerequisite is met.
For several score bands or categories, IFS may make the logic more readable. For counting or summing values that meet criteria, COUNTIF and SUMIF are often better choices because they perform the aggregation directly. For handling an error in a calculation, IFERROR is designed to return an alternative result when an expression produces an error; it is not a substitute for checking every business condition with IF.
For example, assume a division calculation uses the amount in A2 and the divisor in B2:
=IFERROR(A2/B2,"Check values")
This shows Check values if the calculation produces an error, such as division by zero. It can make a report easier to read, but broad error handling may also hide an unexpected problem. Use it when an alternative message is genuinely useful, and keep the underlying data and logic clear.
Frequently Asked Questions
What is the correct IF formula in Google Sheets?
Use =IF(condition, value_if_true, value_if_false) with a logical condition and the two results. The false result is optional; if omitted, Sheets returns FALSE when the condition is false.
Can Google Sheets IF return text?
Yes. Put the text in straight double quotation marks, as in =IF(A2>=60,"Pass","Fail"). Cell references and numbers do not need quotation marks.
How do I write an IF formula with multiple conditions?
Put AND or OR inside the condition: AND requires every listed test to be true, while OR requires at least one. Use nested IF or IFS when you need to return different results for several separate cases.
Why does my Google Sheets IF formula show a formula parse error?
Check that the arguments use the separator required by your spreadsheet locale, that text is quoted, and that parentheses are balanced. Also make sure comparison operators and cell references are typed correctly.
Can IF leave a cell blank?
Yes. Use an empty string, written as two double quotes, for the result you want to look blank. The cell still contains a formula, so it is not the same as a cell that has never had a value or formula.
Does Google Sheets IF work the same way as Excel IF?
The basic three-part logic is similar in Google Sheets and Excel. Both use IF for a true-or-false test, but formula separators can vary with locale, and other spreadsheet features or functions may differ. If sharing a file between the programs, check formulas and locale-dependent settings in both.
Related
- How to Find Duplicates in Excel Quickly and Accurately
- How to Find Duplicate Names in Excel Without Guessing
- How to Keep Track of Your Budget in Excel: Step by Step
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Clear Browser Cache in Outlook on the Web SafelyTo clear the browser cache for Outlook on the web, open your browser’s privacy settings and delete cached…
- Clear Cache in Microsoft Outlook: Windows, Mac & MobileTo clear cache in the Microsoft Outlook app, use the method for your device: repair or reset new…
- Excel Dropdown List Based on Cell Value: How to Set It UpYes. In Excel for Microsoft 365, make a dependent dropdown by using the value in one cell to…
- How to Insert Images in an Excel TableTo insert an image into an Excel table, select the destination cell, choose Insert > Pictures > Place…
- Export Phone Contacts to Outlook on iPhone and AndroidTo export phone contacts to Outlook, save them from your iPhone or Android phone as a contact file,…
- How to Delete a Single Page in Word SafelyTo delete a single page in Word, click anywhere on it, press Ctrl+G on Windows (Option+Command+G on Mac),…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.