In Google Sheets, the IF formula checks whether a condition is true and returns one value if it is, and another value if it is false. For example, if a score is in A2, enter =IF(A2>=70,"Pass","Retake") in another cell: a score of 82 returns Pass, while a score below 70 returns Retake.
What the IF formula does
IF is a logical function: it evaluates a test, then chooses between two outcomes. Its three parts are the condition to check, the result for a true condition, and the result for a false condition. Text results need double quotation marks; numbers and cell references generally do not. The condition can use comparison operators such as >, <, =, >=, <=, or <> (not equal).
For example, A2>=70 asks whether the value in A2 is at least 70. If the test is true, the formula returns the first outcome; otherwise, it returns the second. The result may be text, a number, a date, or another formula. IF does not change the original value in the cell being tested: it displays a result in the cell containing the formula.
In Google Sheets in a web browser, type the formula into a cell and press Enter. To apply it to more rows, select the formula cell and drag its small blue fill handle down, or copy and paste it. Relative references adjust as the formula moves: A2 becomes A3 in the next row. Use dollar signs, as in $A$2, when a reference should stay fixed as you copy the formula.
A basic pass-or-fail example
Suppose a class score is recorded in A2 and a passing score is 70. With the score in A2, enter this formula in B2:
=IF(A2>=70,"Pass","Retake")
If A2 contains 82, B2 displays Pass. If A2 contains 64, it displays Retake. The comparison includes 70 because the operator is >=; using > instead would make a score of exactly 70 fail the test. Choose the comparison carefully when boundary values matter, such as eligibility cutoffs, minimum quantities, or target scores.
For a whole class, put each student’s score in column A and the formula in B2, then fill it down. Each row evaluates the score beside it. Keep the source values consistent: numbers stored as text can lead to confusing comparisons or sorting, so check that scores are real numeric values if results look wrong.
Checking for blank cells
IF can identify missing entries, which is useful for intake forms, inventory lists, or incomplete records. With an optional email address in A2, enter this in B2:
=IF(A2="","Missing email","Entered")
If A2 is empty, the result is Missing email; if it contains an address, the result is Entered. The test A2=”” checks whether the cell is empty or evaluates to an empty string. A cell containing spaces is not truly blank, so it may be treated as entered. If users may accidentally type spaces, clean the data rather than assuming the blank check will catch them.
To return a blank result instead of a label, use an empty text string for one outcome. With a delivery status in A2, this formula in B2 displays nothing until the status is Shipped:
=IF(A2="Shipped","Send tracking"," ")
That example contains a space, not an empty string, so it is usually better to use =IF(A2="Shipped","Send tracking","") if the intended result is genuinely blank. An empty-string result can make a cell look empty, but it still contains a formula. This matters for other functions and checks that count cells.
Testing more than one condition with AND and OR
Use AND inside IF when every requirement must be met. For example, a policy might require both a passing score and attendance of at least 90%. With a score in A2 and attendance entered as a percentage in B2, put this in C2:
=IF(AND(A2>=70,B2>=90%),"Pass","Review")
For A2 equal to 84 and B2 equal to 92%, the result is Pass. If either value falls below its threshold, the result is Review. Google Sheets stores 92% as 0.92, and entering 90% in the formula is equivalent to 0.9.
Use OR when meeting any one of several conditions is enough. With annual sales in A2 and a referral flag in B2, enter this in C2:
=IF(OR(A2>=100000,B2="Yes"),"Eligible","Not yet")
If sales are 98,000 but B2 says Yes, the result is Eligible. If sales reach 100,000, the result is also Eligible even if B2 says No. AND and OR can be combined for more involved rules, but write down the rule in plain language first; that makes it easier to check whether the formula matches the intended policy.
Using nested IF formulas for several outcomes
A nested IF places one IF inside another, allowing more than two possible results. This is useful for a small set of grade bands or status labels. With a numeric score in A2, enter this in B2:
=IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","D")))
A score of 86 returns B; 72 returns C; and 68 returns D. The order is important: the formula tests the highest threshold first and proceeds only when the earlier test is false. If the thresholds are rearranged carelessly, a score might receive the wrong category. Decide what should happen at every boundary, including scores exactly equal to 70, 80, or 90.
Nested IF formulas can become hard to read when a rule has many categories. In Google Sheets, alternatives may be clearer for larger decision tables: a lookup table can keep thresholds and labels in visible cells, while IFS can express a sequence of conditions. For a short rule, nested IF is often easy to understand; for a long or frequently changed rule, keeping the criteria in a table is easier to maintain.
Common practical examples: dates and calculations
IF can compare a date with today’s date, which helps flag late tasks. With a due date in B2, enter this formula in C2:
=IF(B2<TODAY(),"Overdue","On time")
If B2 contains a date before the day the sheet recalculates, the result is Overdue; today or a future date returns On time. TODAY updates over time, so this is a live status rather than a permanent record of whether an item was late on a particular date. If you need a historical status, record the relevant date rather than relying on a changing TODAY value.
You can also use IFERROR to give a readable result when a calculation fails. With revenue in A2 and units sold in B2, put this in C2 to calculate revenue per unit:
=IFERROR(A2/B2,"Check quantity")
If A2 is 120 and B2 is 0, division would produce an error, so the formula displays Check quantity. If A2 is 120 and B2 is 4, it returns 30. IFERROR handles errors broadly, not just division by zero, so it can also conceal an unexpected problem in the source data. Use a specific check such as IF(B2=0,…) when you want to handle only a known case and let other errors remain visible.
Common problems and how to fix them
- Missing quotation marks: Text outcomes such as Pass must be enclosed in straight double quotation marks. Cell references and numeric outcomes do not need them.
- Wrong comparison: A formula using >70 does not treat 70 as passing. Use >=70 if the cutoff is inclusive.
- Unbalanced parentheses: Each opening parenthesis needs a matching closing one. Nested IF formulas are especially easy to mistype; check each pair from the inside outward.
- Unexpected text or spaces: A number stored as text, a trailing space in a status, or a blank-looking cell containing spaces can affect a test. Inspect the source value and standardize entries.
- Formula parse error: Google Sheets usually accepts commas between arguments, as in these examples. Some spreadsheet locales use semicolons instead. If Sheets rejects a correctly structured formula, check the spreadsheet’s locale and use the separator it expects.
- Copied formula points to the wrong place: Relative references move when copied. If a threshold is stored in D1 and should remain fixed, reference it as $D$1, for example
=IF(A2>=$D$1,"Pass","Retake").
When debugging, test the condition separately in an unused cell, such as =A2>=70. It returns TRUE or FALSE, helping show whether the issue is the comparison itself or one of the result values. Remove the test cell when you no longer need it.
IF compared with related spreadsheet options
IF is a good fit when a condition leads to one of two outcomes, or when a small number of outcomes can be expressed clearly. AND and OR expand the condition but do not replace IF: they return TRUE or FALSE based on multiple tests, while IF chooses what to show based on that result.
For several independent conditions, Google Sheets also has IFS, which can be easier to read than a long chain of nested IF functions. A lookup table is often more maintainable when categories or thresholds change frequently, because a user can edit the table instead of rewriting a formula. Choose based on how many cases there are and who will need to maintain the sheet; the shortest formula is not automatically the clearest one.
Google Sheets and Excel both support IF, AND, OR, and IFERROR, and the examples here are broadly familiar to Excel users. The instructions are for Google Sheets in a web browser. Excel ribbon paths and some behavior around separators or locale settings can differ, but the basic IF logic is the same.
Frequently Asked Questions
What is the basic IF formula in Google Sheets?
Use IF with a condition, a result for TRUE, and a result for FALSE. For instance, =IF(A2>=70,"Pass","Retake") returns Pass when A2 is at least 70 and Retake otherwise.
Can an IF formula return a number?
Yes. If A2 contains a quantity, =IF(A2>0,A2*2,0) returns twice the quantity when it is positive and returns 0 otherwise. Put the formula in another cell so it does not replace the input.
How do I make an IF formula return a blank?
Use two double quotation marks as the result for the relevant outcome, such as =IF(A2="","",A2). The cell will appear blank when A2 is blank, although the formula cell itself is not empty.
Can IF check text in Google Sheets?
Yes. A comparison such as A2=”Shipped” checks whether the cell contains that text. Text comparisons are generally not case-sensitive in Google Sheets, but extra spaces or different wording can still cause a condition not to match.
Why does my IF formula show a formula parse error?
Check the parentheses, quotation marks, and argument separators first. If your spreadsheet locale uses semicolons, replace the commas between arguments with semicolons. Also make sure text values are quoted and that the formula starts with an equals sign.
Related
- Multi-Level Dropdown List in Excel: How to Create One
- Excel Insert Page Breaks: Steps, Options, and Fixes
- Excel Box and Whisker Plot: How to Create One
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 Freeze One Column in Excel While You ScrollTo keep Excel’s first column visible while you scroll sideways, choose View > Freeze Panes > Freeze First…
- How to Change HTML Email View and Settings in OutlookTo make Outlook compose messages in HTML, change the default message format: in classic Outlook for Windows, go…
- Delete a Blank Page in Word: Step-by-Step GuideTo delete a blank page in Word, turn on formatting marks, find the paragraph mark or break creating…
- Excel Date Difference: Days, Workdays, and Inclusive CountsTo find the number of days between two dates in Excel, subtract the earlier date from the later…
- Share an Outlook Calendar Externally: Steps and OptionsYes. You can share an Outlook calendar with someone outside your organization by inviting their email address and…
- How to Archive Every Email in Outlook Step by StepTo archive every email in Outlook, open each mail folder, select its messages, and choose Archive; repeat for…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.