---
schema_version: "1"
id: b1d2bad77ea1b4058bf5fce4f04e12aa432918e0be9ebf9a465aed784531276e
title: last
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/sales/264-0-0/spiff_function_ref_last.md
canonical_url: https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_last.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 09a02727aa4a8d1d8b72dfd478149fca07e80a3ed2f66176fba8af64c4be4f07
description: Returns the last item in a sorted list in Salesforce Spiff.
products:
  - Sales Cloud
  - Sales Enablement
release: "264"
---
# last

Returns the last item in a sorted list in Salesforce Spiff.

### 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

```
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()` and `transform_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

- [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.")