---
schema_version: "1"
id: fb5c175e826965108470bb84bed65cef960a091bab762ba56e11b70fa527f8c7
title: choose
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/sales/264-0-0/spiff_function_ref_choose.md
canonical_url: https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_choose.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: c30579d38313e93202a391b26344dacaab3f4bae82e7b6c06bf0506e8ab09b00
description: Returns a value from a list based on a specified index in Salesforce Spiff. List values in Spiff aren't sorted by any default order. To make sure that you select the appropriate value, combine this function with sort() so that you sort the list values before you select a specific index.
products:
  - Sales Cloud
  - Sales Enablement
release: "264"
---
# choose

Returns a value from a list based on a specified index in Salesforce Spiff. List values in Spiff aren't sorted by any default order. To make sure that you select the appropriate value, combine this function with `sort()` so that you sort the list values before you select a specific index.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: both Salesforce Classic (not available in all orgs) and Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available for an additional cost in: <strong>Professional</strong> Edition with Web Services API Enabled</td></tr></tbody></table>

## Syntax

```
choose(index_number, list)
```

## Arguments

  
| Argument | Required? | Description |
| --- | --- | --- |
| index\_number | Required | An integer that specifies the index value of the item in the list that you want to choose. The first item in the list has an index of `1`, and the last item in the list has an index of `-1`. |
| list | Required | The items to choose from. The list can contain strings, numbers, records, or data filters, and can include identical entries. Enclose the list in brackets with comma-separated values. This list isn’t sorted by any default order. |

## Example

Choose the largest deal from a list of deals closed in a specific period, ClosedInPeriod. Sort the list by DealAmount in descending order, so that the list values go from largest deal amount to lowest. From the sorted list, select the first value, which represents the largest deal.

```
=choose(1, sort(ClosedInPeriod, DealAmount, -1))
```

If the list is empty, this function returns an error. To add check for an error, enclose the function in an `iferror()` function and show an error message.

```
=iferror(choose(1, sort(ClosedInPeriod, DealAmount, -1)), "Error message to show")
```

#### See Also

- [sort](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_sort.htm&release=264.0.0&type=5 "Organizes records in a Salesforce Spiff data filter by a date, string value, or number value and returns a list of sorted records.")
- [transform\_list](https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_transform_list.htm&release=264.0.0&type=5 "Applies an expression to each record in a data filter in Salesforce Spiff and returns a new list with the results. For example, identify a specific field from a list of records and return a list of the values for only that field from those records.")