# Decision Functions

Learn how to use program flow functions in expressions in ActiveReportsJS.

## Content



### Choose

Returns a value on the specified position from the list

**Syntax**

Choose(```index```, ```Value1```[, ```Value2```,...[, ```ValueN```]])

**Arguments**

* ```index``` - the one-based position of the value you want to return
* ```Value1```, ```ValueN``` - the list to return a value from

**Examples**

You can use the following expression to return the report header based on the ```DataToDisplay``` parameter value.

```js
Choose(@DataToDisplay, "Current Year", "Actual-Prior Year")
```


### IIF

Returns one of two values depending on whether the expression is true or not.

**Syntax**

Choose(```expression```, ```trueReturn```, ```falseReturn```)

**Arguments**

* ```expression``` - an expression that should evaluate to a boolean value
* ```trueReturn``` - the value to return if the expression evaluates to true
* ```falseReturn``` - the value to return if the expression evaluates to false

**Examples**

You can use the following expression to return the color of text based on the ```SalesAmount``` field value.

```js
{IIF(SalesAmount >= 1000, "Green", "Red")}
```

### Switch

Returns the value associated with the first expression in a series that evaluates to true

**Syntax**

Switch(```Expression1```, ```Value1```[, ```Expression2```, ```Value2```,...[, ```ExpressionN```, ```ValueN```]])

**Arguments**

* ```Expression1```...```ExpressionN``` - expressions that should evaluate to a boolean value
* ```Value1```...```ValueN``` - values associated with expressions

**Examples**

You can use the following expression to return the sales channel name based on the ```ChannelKey``` field value.

```js
{Switch(ChannelKey = 1, "Store", ChannelKey = 2, "Online", ChannelKey = 3, "Catalog", ChannelKey = 4, "Reseller")}
```