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
Available in: both Salesforce Classic (not available in all orgs) and Lightning
Experience
Available in: Enterprise, Unlimited, and Developer
Editions
Available for an additional cost in: Professional Edition with Web
Services API Enabled
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")
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required Cookies
Always Active
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional Cookies
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising Cookies
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.