IF() – Performs conditional logic

The IF() function returns one value if a specified condition is true, and another value if the condition is false. It is a fundamental tool for decision-making in formulas.

Syntax

IF(condition, value_if_true, value_if_false)

  • condition: A value or logical expression that can be evaluated as TRUE or FALSE (e.g., T1A1 > 10).
  • value_if_true: The value that is returned if the condition evaluates to TRUE.
  • value_if_false: The value that is returned if the condition evaluates to FALSE.

Basic example

IF(T1A1 > 10, "High", "Low")

This example checks if the value in cell T1A1 is greater than 10.

  • If T1A1 contains 15, the function returns "High".
  • If T1A1 contains 5, the function returns "Low".

Supported operators for conditions

Conditions use standard comparison operators:

  • > (greater than)
  • >= (greater than or equal to)
  • < (less than)
  • <= (less than or equal to)
  • == (equal to)
  • != (not equal to)

Key features

  • Logical evaluation: Evaluates a condition and returns different results based on its truthiness.
  • Versatile return values: value_if_true and value_if_false can be numbers, text (in quotes), results of other formulas, or cell references.
  • Nesting: IF() functions can be nested to create more complex, multi-level conditional logic (e.g., IF(condition1, value1, IF(condition2, value2, value3))).

Practical uses

  • Assigning grades based on scores: IF(T1A1 >= 50, "Pass", "Fail").
  • Categorizing data: IF(T1B2 < 100, "Small", "Large").
  • Displaying status messages: IF(T1C3 == 0, "Out of Stock", "In Stock").
  • Performing different calculations based on criteria met.

Common mistakes

  • Text values not in quotes: If value_if_true or value_if_false is literal text, it must be enclosed in double quotes (e.g., "Pass", not Pass).
  • Missing arguments: All three arguments (condition, value_if_true, value_if_false) are required.
  • Overly complex nesting: Deeply nested IF() statements can become difficult to read, debug, and maintain.
  • Incorrect logical operators: Using = for comparison if the system requires == for an equality check in the condition.

Report issue

Features, Pricing, Documentation, Support, Login

MathGrid ©

Features,
Pricing,
Documentation,
Support,
Login

MathGrid ©

Back to top Arrow