> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# Rank

Assigns a rank to each value in the specified column. By default, the sequence begins with rank `1`, and assigns ascending values.

Identical values are considered a tie, and are assigned the same rank. After a tie, the ranking continues with a gap, assigning the next available rank. For example, in a column with the values `[1, 1, 1, 2]`, **Rank** assigns the values `[1, 1, 1, 4]`. The value `2` is ranked `4` because there are three values that tie for rank `1`, and so it is the fourth ranked value. To assign ranks without gaps, use the [RankDense](/docs/rankdense) function.

## Syntax

```
Rank([column], [direction])
```

These are the function arguments:

<dl>
  <dt>
    column
  </dt>

  <dd>
    Optional
  </dd>

  <dd>
    The column referenced to determine rank
  </dd>

  <dt>
    direction
  </dt>

  <dd>
    Optional
  </dd>

  <dd>
    The directional order of column's values:
  </dd>

  <dl>
    <dt>
      “asc”
    </dt>

    <dd>
      Ranks in ascending order, where the smallest values get rank "1"
    </dd>

    <dd>
      Default, when not specified.
    </dd>

    <dt>
      “desc”
    </dt>

    <dd>
      Ranks in descending order, where the largest values get rank "1"
    </dd>
  </dl>
</dl>

## Notes

* **Rank** assigns ranks based on date, time, numeric, alphabetic, or alphanumeric order, depending on the data type of the referenced column.
* When no arguments are specified, **Rank** assigns ranks in ascending order based on any sort applied in the table. The **Rank** column updates when the sort order of the table changes, or when groupings are applied to the table.
* `Null` values are ranked last, after all non-`Null` values when sorted ascending, and before all non-`Null` values when sorted descending.

## Examples

```
Rank([Name Count], "desc")
```

In this example, **Rank** is used to rank female names in Hawaii for the year 2018 by their popularity. The dataset contains a *Name Count* column that shows the number of instances of each name.

With `[Name Count]` as the **column** argument and `"desc"` as the **direction** argument, the name with the largest value in the *Name Count* column has the rank of 1, the next most popular name has a rank of 2, and so on.

![A table shows a list of female names given at birth in the state of Hawaii in descending order based on the Name Count column. A Rank column uses the Rank function to rank each name based on its popularity](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/e1fed8897ec2f3ef17c50ad42c58f70fdad26998395be062dcc876105df6751d/assets/docs-images/5161b87-kk.png)

Duplicate values have the same rank. Ranking continues after a gap equal to the number of duplicates. For example, **Rank** assigns a rank of 4 for the names Mila and Olivia because they have the same **Name Count** value of 50. There is no rank 5, and the next popular name Mia has the rank 6.

```
Rank([Number])
```

Assigns ranks based on the *\[Number]* column in ascending order. `Null` values are ranked last and are tied with one another.

![A table shows a number column with simple numeric examples, including 1, 2, and Null. The Rank column uses the Rank function to rank each row based on the Number, with Null ranked last.](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/e14bb52632ada347fb128e45500acfc7959b5401bef4d93dde4e3050482d2203/assets/docs-images/57f0d78f81ab77603b3a2bc9706ce4b0c9b778ae026bb07f108e7f41efd5b726-rank_null.png)

## Related resources

* [RankDense](/docs/rankdense)
* [RankPercentile](/docs/rankpercentile)
* [RowNumber](/docs/rownumber)