Google Sheets IF Function: How It Works and Examples

How-to basics · Updated November 3, 2026

Google Sheets IF Function: How It Works and Examples

In Google Sheets, use =IF(condition, value_if_true, value_if_false) to return one result when a test is true and another when it is false. For example, if a score is in A2, =IF(A2>=70,"Pass","Review") displays Pass for a score of 70 or higher and Review for a lower score.

What the IF function does

IF is a logical function: it checks a condition and chooses between two outcomes. That makes it useful whenever a spreadsheet needs to apply a simple rule, such as marking an invoice overdue, deciding whether a target has been met, or labeling a quantity as in or out of stock. The result can be text, a number, a date, a cell reference, or another formula.

The basic syntax is IF(logical_expression, value_if_true, value_if_false). The logical expression is the test Sheets evaluates. The second argument is returned if that test is true, and the third is returned if it is false. In a formula, the function name and arguments go inside parentheses, and commas separate the arguments in the standard English-language spreadsheet locale.

For a concrete example, with a student’s score in A2, =IF(A2>=70,"Pass","Review") returns Pass when A2 is 70 or more. If A2 contains 62, the result is Review. The comparison includes 70 because the operator is >=, meaning “greater than or equal to.”

How to enter an IF formula

In Google Sheets in a web browser, click the cell where you want the result, type an equals sign and the formula, then press Enter. You can also begin typing =IF( and follow the function suggestions. The formula goes in the result cell, not in the cell that contains the value being tested.

  1. Choose the cell that should show the outcome, such as B2.
  2. Enter a formula that refers to the input cell, such as A2.
  3. Press Enter and check the result against the value in A2.
  4. To apply the rule to other rows, select the formula cell and drag its small blue fill handle down, or copy and paste it into the rows below.

With scores in A2:A20 and the outcome starting in B2, enter =IF(A2>=70,"Pass","Review") in B2 and fill it down. Sheets normally adjusts the relative reference for each row, so B3 tests A3, B4 tests A4, and so on. If the same threshold is stored in D1 and should remain fixed when copying, use an absolute reference: =IF(A2>=$D$1,"Pass","Review"). The dollar signs keep the reference pointed at D1.

Writing conditions with comparisons

An IF condition commonly compares a cell with a number, text, or another cell. The main comparison operators are = for equal to, <> for not equal to, > for greater than, < for less than, >= for greater than or equal to, and <= for less than or equal to. A condition can also test whether a cell is blank.

  • With units in A2, =IF(A2=0,"Out of stock","In stock") labels zero as out of stock.
  • With a payment status in A2, =IF(A2="Paid","Complete","Follow up") checks whether the text is Paid.
  • With a due date in A2, =IF(A2<TODAY(),"Overdue","Not overdue") compares the date with today. TODAY updates as the date changes, so this result can change without editing the formula.

Text values that you type directly into a formula need double quotation marks; cell references do not. In the payment example, "Paid" is typed text, whereas A2 refers to a cell. For the date example, A2 must contain a real spreadsheet date, not merely text that looks like a date. A common mistake is to put quotation marks around a reference, as in "A2"; that makes it text rather than a reference to the cell.

Returning a blank or handling missing input

Sometimes a result should stay empty until someone enters an input. Otherwise, a formula copied far down a sheet may display a result for rows that have not been filled in. To check for a blank first, with the input in A2 and the result in B2, use =IF(A2="","",IF(A2>=70,"Pass","Review")). If A2 is empty, B2 displays nothing; otherwise it checks whether the score meets 70.

The first pair of quotation marks represents an empty text value, not a space. This check also treats a cell containing a formula that returns an empty string as empty for this comparison. However, it is not the same as checking whether a cell is physically empty in every possible context. If distinguishing a genuinely empty cell from a formula-generated blank matters, consider using ISBLANK(A2) as the condition instead.

Take care with zero. A2 containing 0 is not the same as A2 being empty, so the blank-check formula proceeds to test zero as a score. That may be exactly right for a grading sheet, but not for every workflow. Decide what empty cells and zeros should mean before copying the formula through a large data range.

Combining multiple conditions

One IF can test several requirements by using AND or OR inside its condition. AND is true only when all of its conditions are true; OR is true when at least one is true. This lets a formula keep a single pair of outcomes while making the test more specific.

With a score in A2 and attendance percentage in B2, =IF(AND(A2>=70,B2>=80),"Eligible","Not eligible") returns Eligible only when the score is at least 70 and attendance is at least 80. If either requirement is missed, it returns Not eligible. With the same layout, =IF(OR(A2>=90,B2="Approved"),"Priority","Standard") returns Priority when the score reaches 90 or the status says Approved.

For several different outcomes, you can place one IF inside another. With a score in A2, =IF(A2>=90,"A",IF(A2>=80,"B",IF(A2>=70,"C","Needs improvement"))) assigns A for 90 or more, B for 80 through 89, C for 70 through 79, and Needs improvement below 70. The order matters: Sheets checks the tests from left to right and returns the result for the first true test. Because scores of 90 also meet the lower thresholds, the highest threshold must appear first.

When to use IFS instead of nested IF

For a series of conditions with a different result for each one, Google Sheets also supports IFS. It checks condition-result pairs in order and returns the result for the first condition that is true. For the same score thresholds in A2, =IFS(A2>=90,"A",A2>=80,"B",A2>=70,"C",TRUE,"Needs improvement") gives the same letter-grade result as the nested formula.

The final TRUE condition acts as a fallback, so the formula has an outcome even when none of the score thresholds is met. Without a condition that covers the remaining cases, IFS can return an error when no condition is true. IFS is often easier to scan when there are several alternatives, while a nested IF may be more familiar or appropriate for a short rule. For only two outcomes, plain IF is usually clearer.

Do not confuse IFS with a lookup table. If a sheet has many thresholds that change regularly, keeping the thresholds and labels in a separate table and using a lookup can be easier to maintain than editing a long formula. The right choice depends on how often the rules change and whether readers need to inspect them in the cells or in a formula.

Common errors and ways to troubleshoot

If a formula is rejected, first check its commas, parentheses, and quotation marks. Every opening parenthesis needs a closing one, and text typed into the formula needs straight double quotation marks. In some spreadsheet locales, the argument separator is a semicolon rather than a comma. If Sheets reports a formula parse error, check the spreadsheet’s locale and use the separator expected there.

  • Unexpected result: Check the comparison operator and the order of nested tests. >70 excludes 70, while >=70 includes it.
  • Text does not match: Check spelling and spaces in both the cell and the formula. For text checks, a cell containing Paid followed by a space may not behave like a cell containing exactly Paid.
  • Numbers behave like text: A number imported or entered as text may not compare as intended. Check the cell’s contents and formatting, and convert the data to numeric values if necessary.
  • Copied formulas point to the wrong place: Use dollar signs to lock a reference that should not shift, such as $D$1 for a shared threshold.
  • Formula is displayed rather than calculated: Check whether the cell is formatted as plain text or whether the entry begins with an apostrophe. Change the cell to an appropriate number format and re-enter the formula if needed.

For a complicated rule, test each part separately. For example, put =A2>=70 in an unused cell to see whether the comparison returns TRUE or FALSE, then add the IF around it. This can reveal whether the problem is the underlying data, the comparison, or the overall formula structure.

IF versus conditional formatting

IF changes the value displayed by a formula cell. Conditional formatting changes how a cell looks when a rule is met; it does not replace the cell’s contents with a label such as Pass. If the goal is to color low scores red while leaving the original scores visible, select the cells and use Format > Conditional formatting in Google Sheets, then create a rule for the desired condition.

You can use both tools together. An IF formula can display a status such as Late or On time, while conditional formatting highlights Late in red. Choose IF when you need a calculated result that can be referenced elsewhere, copied, counted, or used in another formula. Choose conditional formatting when the value should remain unchanged and the visual signal is enough.

Google Sheets and Excel differences

The basic IF function and examples in this guide also work in modern Excel: its familiar syntax is IF(logical_test, value_if_true, value_if_false). IF, AND, OR, and IFS are available in both programs, though the interface for entering and managing formulas differs. This guide’s steps and menu path refer to Google Sheets in a web browser, not Excel’s ribbon.

One practical difference is regional settings. A spreadsheet set to a locale that uses semicolons for function arguments may expect semicolons rather than commas. Date display and interpretation can also vary with locale. When sharing a sheet or moving formulas between products, verify the separators, date values, and results rather than assuming every file uses the same regional conventions.

Frequently Asked Questions

What is the simplest IF formula in Google Sheets?
With a value in A2, =IF(A2>0,"Yes","No") returns Yes when A2 is greater than zero and No otherwise. Replace the condition and outcomes with the rule your sheet needs.

Can Google Sheets IF check text?
Yes. For example, with a status in A2, =IF(A2="Done","Closed","Open") checks whether the cell matches Done. Put typed text in double quotation marks and check for extra spaces if the result is surprising.

Can IF return a blank?
Yes. Use an empty text value, written as "", for an outcome that should appear blank. For instance, =IF(A2="","","Entered") displays nothing when A2 is blank and Entered when it contains a value.

How many IF statements can I nest?
Google Sheets permits nested functions, but a long chain becomes difficult to read and maintain. For a few cases, nested IF can work; for multiple condition-result pairs, consider IFS or a separate lookup table. Keep the rules ordered so the first matching condition is the intended one.

Why does my IF formula show a parse error?
Check that the parentheses are balanced, text is enclosed in double quotation marks, and the argument separator matches the spreadsheet’s locale. A formula copied from a different locale may use commas where the current sheet expects semicolons, or the reverse.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.