How to Use the IF Function in Google Sheets
Return one value when a test is true and another when it is false with the IF function in Google Sheets, including nested IF, IFS, and AND or OR tests.
Column B holds test scores and you want column C to say Pass or Fail. IF checks a condition and returns one value when it is true and a different value when it is not.
Type the basic formula
=IF(B2>=50, "Pass", "Fail")
conditionis the test, here whether B2 is 50 or more.value_if_trueis what to show when the test passes.value_if_falseis what to show when it fails.
With 72 in B2, the cell shows Pass. Copy the formula down and each row tests its own score.
Nest IF for more than two outcomes
=IF(B2>=90, "A", IF(B2>=80, "B", "C"))
The second IF sits in the false slot of the first, so it only runs when the score is below 90. With 85 in B2, the cell shows B. Order the tests from highest to lowest so the first true condition wins.
Use IFS for a cleaner version
=IFS(B2>=90, "A", B2>=80, "B", B2>=0, "C")
IFS takes pairs of condition and result and returns the first pair that is true. The last pair acts as the catch-all. If no condition matches, IFS returns #N/A, so include one that always holds.
Combine conditions with AND or OR
=IF(AND(B2>=50, C2="Yes"), "Pass", "Fail")
AND is true only when every test inside it is true, so this passes a student who scored 50 or more and has Yes in C2. Swap in OR to pass when either test is true: =IF(OR(B2>=50, C2="Yes"), "Pass", "Fail").
Return a number or a calculation
=IF(B2>100, B2*0.1, 0)
Either result can be a number, a cell reference, or another formula. With 250 in B2, the cell shows 25.
About the result types. Text results go in double quotes, numbers do not. To leave a cell blank when the test fails, use an empty string as the result: =IF(B2="", "", B2*2) shows nothing until B2 has a value.
More Google Sheets how-tos
- How to Add a Checkbox in Google Sheets
- How to Add a Drop-Down List in Google Sheets
- How to Filter Data in Google Sheets
- How to Freeze a Row in Google Sheets
- How to Highlight Cells with Conditional Formatting in Google Sheets
- How to Make a Chart in Google Sheets
- How to Merge Cells in Google Sheets
- How to Protect a Range in Google Sheets
- How to Remove Duplicates in Google Sheets
- How to Split Text into Columns in Google Sheets
- How to Sum a Column in Google Sheets
- How to Use COUNTIF in Google Sheets
- How to Use IMPORTRANGE in Google Sheets
- How to Use SUMIF in Google Sheets
- How to Use VLOOKUP in Google Sheets