You are here:
last
Returns the last item in a sorted list in Salesforce Spiff.
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
last(list, sort_expression)Arguments
| Argument | Required? | Description |
|---|---|---|
| list | Required | The list to evaluate. Use any function that returns a list or enter a list manually. A list can contain strings, numbers, currencies, records, or objects. Enclose the list in brackets with comma-separated values. |
| sort_expression | Optional | An expression that specifies how items in the list are sorted. This argument is helpful when you're sorting values in a datasheet field. To sort records in ascending order, specify the name of the field. |
Considerations
- This function's return value is the last item in the sorted list.
- If the list contains only one record or object, the return value is null.
- If the list contains records or objects, each record or object has multiple fields. Specify the field you want to sort by.
- Combine this function with other functions that return lists, such as
sort()andtransform_list().
Examples
Sort records in the ClosedInPeriod_ARRCommission datasheet by the values of the ARR__c field in ascending order, and return the last item.
=last(ClosedInPeriod_ARRCommission, ARR__c)Sort the ARR__c values in ascending order, transform the list to return specific values, and then return the last value from the transformed list.
=last(transform_list(sort(ClosedInPeriod_ARRCommission, ARR__c, 1), ARR__c))See Also
Did this article solve your issue?
Let us know so we can improve!

