Description
Tests a Boolean argument and returns a value if the argument is True or another value if it is False or BLANK
. Multiple IF functions can be nested to test multiple conditions at the same time.
Syntax
IF(Logical Test, Value if True [, Value if False or BLANK])
Arguments
Argument | Type | Dimensions | Description |
---|---|---|---|
Logical Test (required) | Boolean | Any Dimensions | Boolean to test against that determines the values returned by the function. |
Value if True (required) | Any | Any Dimensions | The return value if the corresponding Logical Test value is True. |
Value if False or BLANK (optionnal) | Same as Value if True | Any Dimensions | The return value if the corresponding Logical Test value is False or |
Returns
Type | Dimensions |
---|---|
Same Type as Value if True and Value if False or BLANK | All Dimensions of the three arguments |
It is recommended that the function is used with matching Dimensions as it makes it easier to read and understand. However, the function accepts any sets of Dimensions on its arguments and Pigment automatically allocates missing Dimensions on arguments to make them match. The resulting set of Dimensions is the combination of all Dimensions used in the arguments.
Examples
Formula | Result | Description |
---|---|---|
| 1 | The Logical Test is always True in this example so the result is expectedly 1. |
| “Large Account” if the given Revenue is greater than 1000. | |
| “Large Account” if the given Revenue is greater than 1000. | Multiple nested IFs are used to test multiple conditions at the same time. |
Example in a Complete Formula
Here are some examples of how to use IF with AND, OR, and NOT:
AND :
IF(Country = Country."France" AND Revenue > 1000, "Wow this is crazy good!")
OR:
IF(Country <> Country."France" OR Revenue < 1000, "Not so great!")
NOT:
IF(NOT Country.'Has Sea Border', "No boats for you")
When using the NOT operator in formulas, keep in mind that
NOT(blank)
does not evaluate toTRUE
—onlyNOT(FALSE)
does. It's important to distinguish betweenblank
andFALSE
, as they can appear similar in cells with a Boolean data type.
See also
Excel: IF(logical_test, value_if_true, [value_if_false])
Related articles: SWITCH