---
schema_version: "1"
id: 55787e3ace24a5d4c0c438a0d9844aac5f4eaafe45cc4febcf0560de584eafe5
title: rank
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/sales/264-0-0/spiff_function_ref_rank.md
canonical_url: https://help.salesforce.com/s/articleView?id=sales.spiff_function_ref_rank.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: ee9c7e7bb59c5ee28ac53e58ec6a7f0a944a2fc2994025b424122bf2c4c77bf0
description: Compares a list of filtered numbers that represent rep metrics in Salesforce Spiff, such as monthly attainment, and returns a ranking relative to the rest of the list. This function doesn't break ties and awards the same ranking to all numbers that tie.
products:
  - Sales Cloud
  - Sales Enablement
release: "264"
---
# rank

Compares a list of filtered numbers that represent rep metrics in Salesforce Spiff, such as monthly attainment, and returns a ranking relative to the rest of the list. This function doesn't break ties and awards the same ranking to all numbers that tie.

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

```
rank(target, filter, rank_by)
```

## Arguments

  
| Argument | Required? | Description |
| --- | --- | --- |
| target | Required | The field or object that you want to rank. |
| filter | Required | A data filter that specifies the data that you want to use for ranking. |
| rank\_by | Required | The criteria for sorting and ranking the filtered data. |

## Example

Create a rollup data filter named AE\_Leaderboard, based on the User object, that returns the users from different AE teams. Rank users in this data filter by the output of the LeaderboardMonthlyAttainment calculation.

```
=rank(user, AE_Leaderboard, LeaderboardMonthlyAttainment)
```

By default, this function's return ranking sorts data from lowest to highest. If you sort five users by monthly attainment, the rep with the highest attainment is ranked fifth.

To invert the ranking results so that the rep with highest attainment is ranked first, use the output of the `rank()` function in another formula. If you're sorting five users, maybe you have another calculation, Total\_AEs, that counts the number of users, subtracts the rank, and adds 1.

```
=Total_AEs - rank(user, AE_Leaderboard, LeaderboardMonthlyAttainment) + 1
```

![The rank function used in a formula to invert the default ranking](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-sales-sales_performance_management-264-0-0-production-enus/b1f2feb4-26b8-444f-97f7-be2349869d93/sales_performance_management/images/spiff/spiff_function_ref_rank.png)