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")
  • condition is the test, here whether B2 is 50 or more.
  • value_if_true is what to show when the test passes.
  • value_if_false is 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