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

# Ntile

> Use the Sigma Ntile function to assign the rows of a column to a given number of ranks.

The **Ntile** function assigns the rows of a column to a given number of ranks. An approximately equal number of rows is given each **Ntile** rank. The ranks are assigned in order.

## Syntax

```
Ntile(ranks, [Column], direction)
```

Function Arguments:

* **ranks** (required) - The number of ranks to assign. Must be an integer greater than 0.
* **\[Column]** (required) The column used to rank the table.
* **direction** (optional) The direction to sort the input column. Enter “asc” to sort ascending and “desc” to sort descending. The default sort is ascending.

## Example

```
Ntile(4, [Population 2010])
```

A table contains the population of different counties in 2010.  The table is grouped by a `[State]` column. Using the **Ntile** function, an equal number of rows will be ranked 1, 2, 3 and 4 according to the size of the `[Population 2010]` column. Since the direction is not specified it will default to ascending. Therefore, the lowest quartile of values in `[Population 2010]` will be ranked 1 and the highest quartile of values will be ranked 4.

![](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/887a8405bf6457d73060b6d3ccd3e6d79d3ddaac3dfc25029f4307a8659b3220/assets/docs-images/bd3a7b0-1.png)

```
Ntile(4, [Population 2010], "desc")
```

Here, the direction argument is `"desc"`, so the rank will be assigned descending. Therefore, the highest quartile of values in `[Population 2010]` are ranked 1 and the lowest quartile of values are ranked 4.

![](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/7947da98aa1703e10a75f46114324030ea7a4e5500cb127f6aa776d41fe1a811/assets/docs-images/3a3e800-2.png)

## Related resources

* [Rank](/docs/rank)
* [BinRange](/docs/binrange)