IF

The IF function allows you to make logical comparisons between a value and what you expect.

So an IF statement can have two results. The first result is if your comparison is True, the second if your comparison is False.

Syntax

IF(logical_test, true_result, [false_result])

  • logical_test: Required, this must be a logical equation, either comparing values or strings that must resolve in a true or false answer
  • true_result: Required, this provides the result if the logical_test returns true
  • false_result: Optional;, this provides the result if the logical_test returns false, if not supplied, returns an empty cell

Specifics

  • The true_result and false_result must always be text or numbers, for example “yes” or 10, no other values are supported.
  • The following operators can be used in the logical_test
    • = (equal sign)
    • > (greater than sign)
    • < (less than sign)
    • >= (greater than or equal to sign)
    • <= (less than or equal to sign)
    • <> (not equal to sign)
    • + (plus sign)
    • – (minus sign)
    • * (asterisk)
    • / (forward slash)
  • All String comparisons are case sensative, therefore “yes” = “Yes” is false.
  • Use parenthesis to set calculation order if necessary, eg. (2 + 3) * 5

Examples

  • =IF(C2=”Yes”,1,2)
  • =IF(C2=1,”Yes”,”No”)
  • =IF(C2>B2,”Over Budget”,”Within Budget”)
  • =IF(3>2, “Expected”, “I was not expecting this result”)