> For the complete documentation index, see [llms.txt](https://smartbooks.gitbook.io/smartbooks-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smartbooks.gitbook.io/smartbooks-docs/data-models/financial-planning/formulas/iif.md).

# Iif()

The Iif() function evaluates a condition and returns one value if the condition is true and another if it is false.

## Syntax:

Iif(expr, truepart, falsepart)

## **Arguments:**

* **expr**: The expression you want to evaluate.
* **truepart:** The value or expression to return if expr is True.
* **falsepart**: The value or expression to return if expr is False.

## **Logical operators**&#x20;

* **and:** The and operator checks if all provided conditions are true. If every condition evaluates to true, then the entire expression returns true; otherwise, it returns false.&#x20;
* **or:** The or operator checks if any of the provided conditions is true. If at least one condition evaluates to true, then the entire expression returns true; if none of the conditions are true, it returns false.&#x20;

## **Examples:**&#x20;

* To check if the value of Account("9000") is greater than the previous period of account 9000 and if this is true return 1 and 0 if false: \
  Iif(Account("9000") > PreviousPeriod('9000'), 1, 0)&#x20;
* A more complex example using functions in the true/false parts: \
  Iif(Account("9000") > 50, PreviousPeriod("6000") + 1, PreviousPeriod("3000")) \
  In this example, if account 9000 is greater than 50, the function adds 1 to the previous period’s value of account 6000; otherwise, it simply returns the previous period’s value for account 3000.&#x20;
* Another example from a budgeting scenario: \
  If a metric is greater than or equal to a specific value, one calculation is used; otherwise, a different calculation is applied: \
  Iif(Account("{account\_metric}") >= {value}, Account("{account\_metric}") \* 0.15, Account("{account\_metric}") \* 0.1)&#x20;
* An example of using the operators: Iif(Account('8001') > 50 and Account('7001') > 20,1,0)
