# 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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FqtvijKJudHtrNS2GDcCc%2F0.png?alt=media)

**Example**

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F5xG8jPd4eTVAGJvQzr5e%2F1.png?alt=media)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FPDjowNo8lqolxBQEbvEL%2F2.png?alt=media)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FistF5oTqOQ9D0kr23C0z%2F3.png?alt=media)
