IF

The IF function checks if a condition is fulfilled and returns one value in a positive case (if the evaluation of the condition returns the logical value True) and another in the negative case (if the evaluation of the condition returns the logical value False).

Syntax

IF(
    logical_test,
    value_if_true
    [, value_if_false]
)

Parameters
  • logical_test: Condition to evaluate (which must return a True or False value) that will determine the return of the value value_if_true or the value value_if_false.
  • value_if_true: Value to return if the logical_test condition is evaluated as true.
  • value_if_false: Optional parameter. Value to return if the logical_test condition is evaluated as false.
Returned value

The IF function can return a value of any type.

Additional Information

If logical_test refers to a column, the IF function returns the appropriate value for the current row. In this case, IF tries to return the same type of value for all rows. If the type of value_if_true and the type of value_if_false are different, IF will implicitly convert the results to ensure that they all have the same type. If this is not possible (by returning, for example, a text string in one case and a number or a Boolean in another), the function returns an error message:

IF function. Example of use

The value_if_true argument is required. In case the value_if_false argument is not included, the IF function returns a Blank (see example below).

Examples

In this example, each sale is evaluated as "Gran venta" ("Big Sale") or "Pequeña venta" ("Small Sale") depending on whether or not the amount of the sale is greater than € 100,000:

IF function. Example of use

The value_if_false argument is not included in this example. To confirm the type of the result that the IF function returns in the event that logical_test evaluates to False, a new custom column is added with the formula:

Es blank = ISBLANK(Tabla1[Tipo de venta])

IF function. Example of use

Category
Logical
Submitted by admin on Mon, 12/03/2018 - 23:15