GridDojo

How to Use the IF Function in Google Sheets

The IF function in Google Sheets returns one value when a condition is true and another when it is false. The syntax is =IF(condition, value_if_true, value_if_false). Here is exactly how each part works, with examples.

By The GridDojo Team Published 2 min read

IF is the function that lets a spreadsheet make decisions. It checks a condition and returns one thing when it is true and another when it is false — perfect for labels like Pass/Fail, Yes/No, or flagging values that need attention.

The IF syntax, explained

=IF(condition, value_if_true, value_if_false)
The three parts of IF
PartMeaning
conditionA test that is either true or false, like B2>50
value_if_trueWhat to return when the test is true
value_if_falseWhat to return when the test is false

A real example

Say column B has scores. To label each one Pass or Fail based on a 50 cutoff, in cell C2 you write:

=IF(B2>=50, "Pass", "Fail")

This reads: if the score in B2 is 50 or higher, show "Pass"; otherwise show "Fail". Wrap text values in quotation marks; numbers and cell references do not need them.

Testing more than one condition

You can nest an IF inside another to handle several outcomes — for example, grades:

=IF(B2>=80, "A", IF(B2>=50, "B", "C"))

When there are many cases, the IFS function is cleaner than deeply nested IFs. And to test two conditions at once, combine IF with AND or OR, like =IF(AND(B2>=50, C2="Yes"), "OK", "No").

The IF function works almost identically in Excel — see how to use the IF function in Excel. Once your logic is set, you can visualize the results with a graph in Google Sheets.

Frequently asked questions

What is the difference between IF and IFS in Google Sheets?

IF handles one test with a true and a false result. IFS checks several conditions in order and returns the first that is true, which avoids long nested IFs when you have many cases.

How do I use IF with text in Google Sheets?

Put the text in quotation marks and compare with =. For example, =IF(A2="Paid", "Done", "Pending") checks whether A2 says Paid. Text comparisons in Google Sheets are not case-sensitive.

Why does my IF formula show a value everywhere?

Usually the condition is always true or always false. Check that you are comparing the right cell and using the correct operator (>, >=, =). A common slip is comparing a number to text, which never matches.

Sources and references

  1. Google Docs Editors Help — IF function