# If (String)

| **Name**    | ***If (String)***                                                                                                                                                                                                                                                                                             |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Syntax      | If (Boolean condition, String thenValue, String elseValue)                                                                                                                                                                                                                                                    |
| Purpose     | To evaluate a given condition and if true, return result of thenValue. Otherwise, to return the result of elseValue.                                                                                                                                                                                          |
| Description | Returns the value of ‘Then’ expression or ‘Else’ expression depending on the value of condition.                                                                                                                                                                                                              |
| Return Type | String                                                                                                                                                                                                                                                                                                        |
| Parameters  | <p>Condition \[System.Boolean] – Condition that is evaluated</p><p>thenValue \[System.String] – This Parameter’s value is returned if the result of ‘condition’ parameter is true.</p><p>elseValue \[System.String] - This Parameter’s value is returned if the result of ‘condition’ parameter is false.</p> |

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/PBUYr2sK4tuvCL5jtW0y/0.png)

**Example**

We have a *Customers* dataset which we will use to evaluate and transform the *Items* field.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/KvzO9XGfPQTs3Xilod7o/1.png)

In this example we will use the *Expression* object to define the condition, and a *Variables* object to define a string *thenValue* and a string *elseValue*.

Where,

Condition: *Items* = “1”

*thenValue* = FirstItem

*elseValue* ­ = SecondItem

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/2YfDab410lnir6wNG0yb/2.png)

In the output, you can see that string values, FirstItem and SecondItem, have been returned depending on whether the *Items* field condition was met.

![](https://content.gitbook.com/content/zEifS4h8yurLAAwiGNX2/blobs/4nZ4V65qzpdVjb7yZ85x/3.png)
