# How to write an IF Statement in Cascade

If you’re familiar with generic Excel [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) statement Syntax, then you’ll have no problem getting accustomed to writing [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) statements in Cascade.

Firstly, you need a tool with an Expression Editor in order to write an [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) statement. Generally speaking, you will use either a [Filter](https://docs.cascade.io/cascade/tools/transform/filter) tool or an [Edit Columns](https://docs.cascade.io/cascade/tools/transform/editcolumns) tool; these each have an Expression Editor.

<figure><img src="https://2577551913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MW_FvcY52Jcyt8JHFGs%2Fuploads%2FQZPZlCJtxTGORSVK5YMS%2FHow%20to%20write%20an%20IF%20Statement%20in%20Cascade-1.png?alt=media&#x26;token=554d602c-9a79-4a5e-b838-86937f6ac5d1" alt=""><figcaption><p>Configuration window of an <a href="../../tools/transform/editcolumns">Edit Columns</a> tool with an <a href="../../functions-and-expressions/functions/logical/if">IF</a> statement</p></figcaption></figure>

Here is the syntax for an [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) statement in Cascade:

```html
IF( condition, then, else )
```

The `condition` is a boolean expression to test (e.g., whether or not some statement is true).

The `then` is the true variable.

The `else` is the false variable.

So for example, if I wanted to create an [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) statement that will append green apples the value ‘*verte’* and red apples the value ‘***rouge***’, my formula might look something like this:

My [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) statement will look for the value “green” in the `[apple]` column. If the value in the `[apple]` column of a particular row is “green”, then the value ‘***verte’*** would be attributed to that row. If the value is not “green” (e.g., it can be any other value, and we are hoping the only color we might see is red), then the value ‘**rouge**’ would be attributed to that row.

[IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) statements can appear somewhat complex when nesting many conditions and operands. However, there are other [Functions](https://docs.cascade.io/cascade/functions-and-expressions) available to make writing complex [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) statements with multiple conditions.

### Related Questions

<details>

<summary>How do I know when to use an IF Statement in Cascade?</summary>

You can use [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) statements in Cascade when you need to compare values and assign a result based on the outcome of that comparison.

</details>

<details>

<summary>What is the purpose of the IF function?</summary>

The [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) function is used to test a condition and return one value if the condition is TRUE, and another value if the condition is FALSE.

</details>

<details>

<summary>How many arguments does the IF function require?</summary>

The [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) function requires three arguments: a condition, a value if the condition is TRUE, and a value if the condition is FALSE.

</details>

<details>

<summary>What is the syntax of the IF function?</summary>

The syntax of the [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) function is: IF(condition, then, else)

</details>

<details>

<summary>How can I use the IF function to compare multiple values?</summary>

To compare multiple values, you can use the [IF](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if) function in combination with the [AND](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/and) or [O](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/or)R functions.

</details>

### Other Sources

{% content-ref url="../../functions-and-expressions/functions/logical/if" %}
[if](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/if)
{% endcontent-ref %}

{% content-ref url="../../functions-and-expressions/functions/logical/ifs" %}
[ifs](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/ifs)
{% endcontent-ref %}

{% content-ref url="../../functions-and-expressions/functions/logical/iif" %}
[iif](https://docs.cascade.io/cascade/functions-and-expressions/functions/logical/iif)
{% endcontent-ref %}
