In Google Sheets, an IF formula checks whether a condition is true and returns one value if it is, and another if it is not. For example, with a score in A2, =IF(A2>=60,"Pass","Fail") returns Pass when the score is at least 60 and Fail otherwise.
What the IF Function Does
IF is a logical function: it evaluates a test and chooses between two outcomes. That makes it useful whenever a spreadsheet needs to label, classify, or make a simple decision from its data. Common uses include marking invoices as paid or overdue, checking whether stock has reached a reorder point, and assigning a result based on a score.
The three parts of the function are the condition to test, the value to return when that condition is true, and the value to return when it is false. The last two values do not have to be words; they can be numbers, dates, references to other cells, or another formula. Text results need straight double quotation marks. Cell references and numbers do not.
IF returns a value in the cell containing the formula; it does not change the source data or apply visual formatting by itself. For example, a formula can display the word “Late,” while a separate conditional formatting rule can make that result red. Keeping those roles separate makes a sheet easier to maintain.
Write a Basic IF Formula
Start by deciding what should count as true, then specify the two outcomes. In the example below, the formula tests whether a product’s stock is below 10. With the product name in A2 and its stock count in B2, enter this in C2:
=IF(B2<10,"Reorder","Enough stock")
If B2 contains 7, the result in C2 is Reorder. If B2 contains 10 or more, the result is Enough stock. The less-than operator matters: a stock count of exactly 10 does not meet the condition. Change it to <= if 10 itself should trigger a reorder.
After entering the formula, press Enter. To apply the same logic to more rows, select the cell and drag its small fill handle down, or copy and paste it into the rows below. Relative references adjust as the formula moves: in the next row, B2 becomes B3. If a reference needs to stay fixed when copying, add dollar signs, as in $B$2.
Conditions, Comparisons, and Text
A condition can use comparison operators such as equals (=), not equal to (<>), greater than (>), less than (<), greater than or equal to (>=), and less than or equal to (<=). For instance, an IF test can check whether a date is before today or whether a total is at least a target. Dates in Sheets are stored as numbers, so date comparisons work when the cells contain real date values rather than text that merely looks like a date.
For text comparisons, put the text being checked in quotation marks. With a delivery status in B2, this formula returns Ready only when the cell contains Shipped:
=IF(B2="Shipped","Ready","Not ready")
If B2 contains Shipped, the result is Ready; if it contains another value, the result is Not ready. A common source of unexpected results is extra spaces or inconsistent wording, such as “Shipped ” with a trailing space or “shipped” in a different capitalization. Clean or standardize the input values if the test is not matching as expected.
To compare a cell with a value in another cell, refer to that cell rather than putting the reference in quotation marks. For example, a target stored in D2 can be compared with a sales figure in C2. Quotation marks around D2 would make Sheets look for the literal text D2 instead of using the value in that cell.
Combine Tests with AND and OR
Sometimes one condition is not enough. AND returns true only when every condition supplied to it is true; OR returns true when at least one condition is true. Place either function inside IF to choose an outcome based on multiple tests.
With a shipping status in B2 and payment status in C2, this formula marks an order Ready only when it has shipped and been paid:
=IF(AND(B2="Shipped",C2="Paid"),"Ready","Hold")
If B2 is Shipped but C2 is Unpaid, the result is Hold. Both tests must be true for Ready to appear. This is useful for approval checks where all requirements must be met, such as a completed form with both a name and a date.
With a priority label in B2 and an order amount in C2, this formula flags an order for review if it is marked Urgent or its value is at least 500:
=IF(OR(B2="Urgent",C2>=500),"Review","Standard")
If B2 is Standard and C2 is 620, the result is Review because one of the two conditions is true. Be precise about whether your rule requires all conditions or any condition; swapping AND for OR changes the meaning of the decision.
Use Nested IF or IFS for Several Outcomes
When a decision has more than two possible results, one option is to place another IF inside the first. The order of tests matters: Sheets checks them in sequence and returns the result for the first condition that is true. With a numeric score in A2, this nested formula assigns a letter grade:
=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","D")))
If A2 is 84, the result is B: the first test is false, and the second is true. A score below 70 returns D. The final result acts as the catch-all for values that fail every earlier test, so consider what should happen with blank cells or scores outside the expected range.
For the same score in A2, IFS offers a flatter way to list multiple tests:
=IFS(A2>=90,"A",A2>=80,"B",A2>=70,"C",TRUE,"D")
A score of 84 also returns B. The final TRUE condition provides a default result when none of the score thresholds match. IFS can be easier to read when there are many branches, while nested IF can be useful when each branch needs more involved logic. In either case, put more restrictive or higher-priority tests first so an earlier condition does not capture values intended for a later result.
Handle Blank Cells and Errors Carefully
A blank cell can behave unexpectedly in a comparison. If a blank input should produce a blank result instead of a label, test for blank first. With a target value in A2, this formula leaves the output empty when A2 is blank and otherwise checks whether it has reached 100:
=IF(A2="","",IF(A2>=100,"Target met","Below target"))
If A2 is empty, the formula returns an empty string, which looks blank but is still a formula result. If A2 contains 85, it returns Below target; if A2 contains 100, it returns Target met. A cell containing a space is not truly empty, so it will not pass the blank check. If data may contain spaces, clean it or account for that possibility explicitly.
IFERROR is a separate function that can provide a fallback when a calculation produces an error. With a total in A2 and a quantity in B2, this formula calculates the unit amount unless division fails:
=IFERROR(A2/B2,"Check denominator")
If A2 is 100 and B2 is 0, the formula returns Check denominator rather than a division-by-zero error. But IFERROR also catches other errors, which can hide problems such as a misspelled reference. Use a clear message and investigate the underlying cause instead of treating every error as harmless.
Fill a Whole Column and Format Results
For a small table, copying an IF formula down is usually straightforward. If new rows are added regularly, an array formula can apply the logic to a range. With item names in A2:A and stock counts in B2:B, put this formula in C2, leaving the cells below it in column C clear for the results:
=ARRAYFORMULA(IF(A2:A="","",IF(B2:B>=10,"In stock","Low")))
For each nonblank item name, the formula returns In stock when the corresponding count is at least 10 and Low otherwise; rows without an item name remain blank. Because the result expands down the column, do not put other values in the cells where it needs to display. Array formulas are helpful for growing lists, but a copied formula may be easier to understand in a short or irregular table.
To color results based on their displayed values, select the relevant range and use Format > Conditional formatting. Set a rule for text that is exactly “Low,” then choose a formatting style. This changes how matching cells look, not what the IF formula returns. Conditional formatting is often preferable to adding color logic to a formula because the result remains usable as ordinary text.
Common Mistakes and Troubleshooting
- Missing quotation marks: Text outcomes such as Reorder need quotation marks. Without them, Sheets may interpret the word as a named range.
- Wrong comparison boundary: >10 excludes 10, while >=10 includes it. Check whether the boundary value should qualify.
- Unbalanced parentheses: Each opening parenthesis needs a closing one, especially in nested IF formulas. Read the formula from the innermost test outward.
- Unexpected text match: Look for spaces, inconsistent labels, or numbers stored as text. A value that looks numeric may not behave like a number in comparisons.
- Formula parse error: Google Sheets uses separators based on spreadsheet locale. If commas are rejected, check File > Settings and the locale; some locales use semicolons between arguments.
- Array output blocked: Clear cells in the intended output range. An existing value can prevent an array formula from expanding.
The IF function itself is the same idea in Google Sheets and Excel, and a simple formula often looks identical in both. However, argument separators can depend on locale in either product, and menus and some advanced features differ. These examples use Google Sheets in a web browser, not Excel ribbon instructions.
Frequently Asked Questions
What is the syntax for IF in Google Sheets?
The function takes a condition, the value to return if the condition is true, and the value to return if it is false. Use commas between these arguments in a comma-based locale; spreadsheet locale settings can affect the separator.
Can an IF formula return a number?
Yes. Put the number directly in the true or false result position, without quotation marks. Text results should be quoted. A formula can also return a reference or the result of another calculation.
How do I make an IF formula show nothing when a cell is blank?
Test the input for blank first and return an empty string as the true result. Remember that a cell containing a space is not empty, and an empty string from a formula is not the same as a cell with no formula.
Can IF check more than one condition?
Yes. Use AND inside IF when all conditions must be true, or OR when any one condition is enough. For several possible outcomes, use nested IF or IFS and put the tests in the order you want them evaluated.
Why does my Google Sheets IF formula show a parse error?
Check quotation marks, parentheses, comparison operators, and argument separators. If the formula uses commas but your spreadsheet locale expects semicolons, replace the separators or review the locale in File > Settings.
Related
- How to Keep Track of Bills in Excel
- How to Keep Format Painter On in Excel for Multiple Cells
- Keep the Home Tab Open in Excel: Show the Ribbon
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Can Excel Read Outlook Emails, Contacts, and Calendar?Yes—Excel can work with Outlook data, but it does not automatically read your mailbox just because both apps…
- Excel Keyboard Shortcut to Insert a NoteIn Excel for Microsoft 365 on Windows, select a cell and press Shift+F2 to insert a note. If…
- INDEX MATCH in Google Sheets: How It Works and ExamplesYes. Google Sheets supports both INDEX and MATCH, and combining them lets you find a value in one…
- Google Sheets Conditional Formatting: Using BordersNo. Google Sheets’ built-in conditional formatting cannot add or change cell borders when a rule is met; its…
- Excel Data Validation: Lists, Rules, and Common FixesIn Microsoft Excel for Microsoft 365 on Windows, data validation controls what users can enter in selected cells.…
- Conditional Formatting in Excel With ColorsIn Excel for Microsoft 365 on Windows, select the cells, then choose Home > Conditional Formatting and pick…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.