# RANK

Returns the rank/position of a number in a list of numbers.

A number's rank refers to its size or value in comparison to the values of other numbers in a list. If you were to sort the list (ascending or descending), the rank of the number would be its position.

If there are duplicates, their rank remains the same. The subsequent rank(s) are skipped.

## Syntax

```javascript
RANK(number, list, [order])
```

## Arguments

The RANK function syntax has the following arguments:

* number: Required. The number whose rank you wish to find.
* list: Required. A list of numbers, or a reference to it.
* order: Optional. A number that specifies whether the numbers should be ranked ascending or descending in the list.

If the order is 0 (zero), Inforiver ranks the number as if the list is sorted in **descending order**. The highest value number is assigned a rank of 1, and so on.

If the order is omitted or any nonzero value is entered, Inforiver ranks the number as if the list is sorted in **ascending order**. The lowest value number is assigned a rank of 1, and so on.

## Example

<pre class="language-javascript"><code class="lang-javascript">RANK(2,[1,3,2,5,4],0)
// returns 4

RANK(2,[1,3,2,5,4],1)
// returns 2

<strong>RANK(2,[1,3,2,5,4])
</strong>// returns 2

// with duplicates
RANK(4,[1,2,2,5,4])
// returns 4
</code></pre>

You can use the RANK function to rank the values of several entities in important metrics like score, cost, revenue, sales, and so on.

In the example below, we have used the RANK function to rank the sales across different product categories.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FX8u2o1Cs4LICMRLBNS2k%2Fimage.png?alt=media&#x26;token=6cf1ec38-d69c-4594-8cd0-071fb7ffbb96" alt=""><figcaption><p>RANK function</p></figcaption></figure>

{% hint style="info" %}
We used the **SELECT** function to select a range of columns from 1 to 5 for the 'Sales' measure.
{% endhint %}

## Excel Equivalent

[RANK](https://support.microsoft.com/en-us/office/rank-function-6a2fc49d-1831-4a03-9d8c-c279cf99f723)
