Free demo · Google Sheets · Lesson 5 · Intermediate · IF function

The IF function: let the sheet decide

IF asks a yes-or-no question and gives one answer when it is true and another when it is false. Here: who has paid the full camp fee?

fx=IF(logical_expression, value_if_true, value_if_false)
Child | Fee | Paid | Status Asha | 1500 | 1500 | =IF(C2>=B2,"Paid","Due")→Paid Kabir | 1200 | 600 | =IF(C3>=B3,"Paid","Due")→Due Zoya | 1800 | 1800 | =IF(C4>=B4,"Paid","Due")→Paid Arjun | 1500 | 0 | =IF(C5>=B5,"Paid","Due")→Due Diya | 1400 | 1400 | =IF(C6>=B6,"Paid","Due")→Paid
  1. 1The question: is Paid at least the Fee?
  2. 2Type =IF(C2>=B2,"Paid","Due")
  3. 3Enter: 1500 ≥ 1500 is TRUE, so Asha is Paid
  4. 4Fill down: every row tests its own numbers
  5. 5Kabir pays the rest: Due becomes Paid by itself
  6. ✓Text in quotes, numbers without: =IF(C2>=B2,0,B2-C2) gives the balance
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. Enrol

Tip: press → or Space to step through, ← to go back, R to replay.

About this lesson

The IF function lets a Google Sheets formula make a decision. It has three parts: a test that is either TRUE or FALSE, the value to show when the test is TRUE and the value to show when it is FALSE. In this lesson =IF(C2>=B2,"Paid","Due") compares the amount a child has paid with the camp fee and writes Paid or Due in a Status column. Text answers go in double quotes; numbers, cell references and whole formulas do not, so =IF(C2>=B2,0,B2-C2) shows the balance that is still due. Copied down with the fill handle, the formula tests every row with its own numbers, and the status changes by itself as soon as a payment is typed in. The full course goes on to AND, OR and NOT for tests with several conditions, IFS and SWITCH for more than two answers, IFERROR for tidy error messages, and COUNTIFS and SUMIFS for counting and adding with conditions.

Key points

  • IF = a test, the answer if TRUE, the answer if FALSE
  • Text answers go in quotes; numbers and formulas do not
  • Fill down: each row is tested and updates by itself