In Google Sheets, an IF statement uses the IF function to test a condition and return one result if it is true and another if it is false. With a test score in A2, enter =IF(A2>=50,"Pass","Fail"); a score of 72 returns Pass, while a score below 50 returns Fail.
What an IF statement does
An IF function lets a spreadsheet make a simple decision based on the contents of a cell. The condition is evaluated as true or false, and the function returns the matching result. That makes IF useful for turning raw values into readable labels, applying a rule to each row, or choosing which calculation to show.
For example, a list of orders might need a status of “Free shipping” when the order total reaches a threshold and “Shipping applies” otherwise. A project tracker might show “Late” when a due date has passed, or a grade sheet might classify scores into categories. The function does not change the source value: it displays a result in the cell containing the formula.
IF is a function, rather than a separate spreadsheet mode or a special statement that must be placed in a particular menu. You type it into a cell like other formulas, usually beginning with an equals sign. Google Sheets recalculates the result when a referenced cell changes.
IF syntax and its three parts
With the score in A2, the formula =IF(A2>=50,"Pass","Fail") has three arguments in this order: the condition to test, the value to return when the condition is true, and the value to return when it is false. In this example, A2>=50 is the test, “Pass” is the true result, and “Fail” is the false result.
Conditions commonly use comparison operators. Use = for equal to, <> for not equal to, > for greater than, < for less than, and >= or <= for greater than or equal to, or less than or equal to. Text results need double quotation marks; cell references and numbers generally do not. For example, the number 0 is written as a number, while a text result such as “No” is enclosed in quotes.
The third argument is optional. With a category in A2, =IF(A2="Complete","Done") returns “Done” when A2 contains Complete and returns a blank cell result when the condition is false. Omitting the false result can be convenient, but it can also make missing or unexpected cases less obvious. If you want a clear outcome for both possibilities, specify both results.
In most Google Sheets files, arguments are separated with commas. A spreadsheet’s locale can use semicolons instead. If a formula copied from elsewhere is rejected despite its logic being sound, check the spreadsheet’s locale under File > Settings and adjust the argument separators to match. The function name and decision logic remain the same.
Build a basic IF formula
To make a basic rule, decide what cell contains the value, write a condition that compares it with a threshold or label, and choose what each outcome should say. For example, with a payment amount in B2, this formula labels amounts of at least 100 as “Eligible”:
With the payment amount in B2, enter =IF(B2>=100,"Eligible","Not eligible"). If B2 contains 125, the result is Eligible; if it contains 80, the result is Not eligible.
To apply the same rule to other rows, put the formula in the first result row and fill it down using the small square at the lower-right corner of the selected cell. Google Sheets adjusts a relative reference such as B2 to B3, B4, and so on as the formula moves. This is usually what you want when each row has its own amount.
You can also compare against another cell instead of typing a fixed threshold into the formula. With an amount in B2 and the minimum amount stored in E1, use =IF(B2>=$E$1,"Eligible","Not eligible"). The dollar signs keep the threshold reference fixed when the formula is filled down, while B2 changes by row. This makes it easier to update the rule later by changing E1 rather than editing every formula.
Use IF with multiple conditions
When a result should depend on more than one test, combine IF with AND or OR. AND returns true only when all its supplied conditions are true. OR returns true when at least one condition is true. With a score in B2 and attendance percentage in C2, use the following to require both a passing score and attendance of at least 80%:
With the score in B2 and attendance entered as a percentage in C2, enter =IF(AND(B2>=50,C2>=80%),"Meets requirements","Does not meet requirements"). A score of 65 and attendance of 90% returns Meets requirements; a score of 65 and attendance of 75% returns Does not meet requirements.
For an either-or rule, with a customer type in A2 and a purchase total in B2, use =IF(OR(A2="Member",B2>=100),"Discount","Standard price"). It returns Discount for a member or for a purchase of at least 100. AND and OR can be nested inside IF, but adding many tests can make a long formula hard to maintain. Consider putting important thresholds or categories in separate cells so the rule is easier to review.
Nested IF and the IFS function
A nested IF places another IF in the true or false result of an existing IF. It is useful when a cell needs more than two categories. With a score in A2, enter =IF(A2>=80,"High",IF(A2>=50,"Medium","Low")). A score of 90 returns High, 65 returns Medium, and 40 returns Low. The formula checks the conditions in order, so the order of the thresholds matters.
For a score of 80, the first test is already true and the later test is not reached. For a score below 80, Sheets checks whether the score is at least 50; if not, it returns Low. Set the most restrictive or highest threshold first in this example. If you put the 50-point test first, a score of 90 would satisfy it and be labeled Medium before the formula could check for High.
For several ordered choices, IFS can be easier to read than a chain of nested IF functions. With a score in A2, use =IFS(A2>=80,"High",A2>=50,"Medium",TRUE,"Low"). It returns the result paired with the first condition that is true. The final TRUE condition acts as a fallback for any score that did not meet the earlier tests; without a matching condition, IFS can return an error. IFS is not interchangeable with every nested IF: when a decision needs different branches at different levels, nested IF may still express the logic more naturally.
Handle blanks, errors, and common mistakes
A frequent surprise is that an empty input may be treated like zero in some comparisons. If blank rows should remain blank, test for a blank explicitly before applying the main rule. With a score in A2, enter =IF(A2="","",IF(A2>=50,"Pass","Fail")). It returns a blank when A2 is empty, Pass for 50 or more, and Fail for a nonblank score below 50.
Another common mistake is using text without quotation marks or putting the arguments in the wrong order. If a formula displays an error, check that the condition comes first, then the true result, then the false result; check that parentheses are balanced; and make sure text labels have straight double quotes. Also check whether your file expects commas or semicolons between arguments.
IF does not automatically convert every kind of input into the intended category. A number stored as text, a misspelled label, or a date entered in an unexpected format can make a condition evaluate differently from what you expect. Test a few ordinary values and the boundary value itself—for a threshold of 50, check 49, 50, and 51. That helps confirm whether the operator should be greater than or greater than or equal to.
If the calculation itself can produce an error, IFERROR is a separate function that can provide a fallback result. It does not replace IF’s true-or-false test. Use it when you specifically want to handle an error from another expression, and avoid hiding errors that should instead be investigated.
IF versus conditional formatting
Use IF when you want the cell to contain a result, such as a status word or a calculated value. Use conditional formatting when the value is already present and you want its appearance to change, such as highlighting overdue dates. Conditional formatting does not write a new label into the cell, so it is not a substitute for an IF formula when the result needs to be read, sorted, or used by another formula.
In Google Sheets in a web browser, select the cells to format and choose Format > Conditional formatting. Under Format rules, choose a rule type or select Custom formula is to define a condition, then choose the formatting style. For instance, if dates are in C2:C100, select that range and use a custom formula that checks whether the date in each row is before today. The formatting rule changes the display; the date value itself remains unchanged.
Google Sheets and Excel both support the IF function with the same general logic and familiar syntax, so a simple IF formula often transfers between them. The menus for conditional formatting and some surrounding features differ between the programs. If you are following steps written for Excel, do not assume its ribbon paths match Google Sheets; in Sheets, use the browser menus described above.
When to choose another approach
IF is a good fit for a small number of clear decisions. For a lookup table of many categories, a lookup function or a dedicated mapping table may be easier to update than a long chain of conditions. For instance, if each product code has a corresponding shipping class, keeping codes and classes in two columns separates the data from the rule and avoids editing a large formula whenever a class changes.
For a simple two-way choice, IF is usually the most direct option. For multiple independent conditions, AND and OR can keep the test readable. For a short sequence of ordered categories, IFS may be clearer than nesting. For visual emphasis without changing cell contents, use conditional formatting. Choosing based on the job makes a sheet easier for another person to check and maintain.
Frequently Asked Questions
How do I write an IF formula in Google Sheets?
Use the order condition, result if true, result if false. With a score in A2, =IF(A2>=50,"Pass","Fail") returns Pass for 50 or more and Fail otherwise. Use commas or semicolons according to the spreadsheet’s locale.
Can Google Sheets IF return text?
Yes. Put text results in double quotation marks, such as “Pass” or “Review.” A result can also be a number, a cell reference, or another formula, depending on what the sheet needs to return.
Can an IF formula have more than two outcomes?
Yes. Nest IF functions or use IFS for a sequence of condition-and-result pairs. Order overlapping conditions carefully, because the first true condition determines the returned result.
What does IF return when the condition is false and no false result is supplied?
If you omit the third argument, Google Sheets returns a blank result for a false condition. Add an explicit false result when you want the outcome to be visible or unambiguous.
Why is my Google Sheets IF formula showing an error?
Check the parentheses, argument order, quotation marks around text, and whether the sheet expects commas or semicolons. Also verify that the referenced cells contain the kind of values your condition expects, especially numbers, dates, or labels.
Related
- Insert Key in Excel: What It Does and How to Use It Safely
- How to Link a Word to a Website in Microsoft Excel
- How to Find Duplicate Values 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
- Free Monthly Budget Template for Google Sheets: SetupYes—Google Sheets can be used for a free monthly budget, either by choosing a budget template from the…
- Creating a Signature in Outlook: Steps and TipsTo create a signature in Outlook, open the signature settings for your version, choose New, write and format…
- How to Add a Running Header in Word 2010 Step by StepTo add a running header in Word 2010, open the document, choose Insert > Header, select a layout,…
- Excel Dependent Dropdown List: Group Choices by CategoryYes. In Excel for Microsoft 365, make a group dropdown and a second dropdown that changes to show…
- Auto Sort Google Sheets: Keep Rows in Order AutomaticallyTo auto-sort a Google Sheets table, use SORT in a separate output area for a live sorted view,…
- Google Sheets COUNTIF for Specific TextTo count cells that contain a particular text value in Google Sheets, use COUNTIF: for example, with status…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.