> For the complete documentation index, see [llms.txt](https://docs-v3.toucantoco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-v3.toucantoco.com/data-management-in-datahub/datasets-in-toucan/preparing-data/overview-of-youprep-tm/compute/rank.md).

# Rank

The Rank step allows you to order your data based on specific values, with options for different ranking methods. This is useful for identifying top performers, prioritizing items, or creating ordered lists within your dashboard.

### Steps parameters

* `Value column to rank` **column(string)\***: the value column that will be ordered to determine rank
* `Sort order` **dropdown\["asc", "desc"]\***: how to order the value column to determine ranking. Either `asc`(ending) or `desc`(ending), `desc` by default
* `Ranking method` **dropdown\["standard", "dense"]\***: either `standard` or `dense`, as explained above
* `Group ranking by` **column(array) (optional)**: if you need to apply the ranking computation by group of rows, you may specify here the columns to be used to constitute groups (see example 2 below)
* `New column name`**(string) (optional)**: if you want to give a custom name to the output column to be created (by default it will be your original column name suffixed by `_RANK`).

### Example

**Input**

<figure><img src="https://1809014303-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZxYYf1KpgarKMgMsDCrw%2Fuploads%2Fgit-blob-dae76bb313cdd6c887f8a7f0f5afda5d99f33c3e%2Frank_input.png?alt=media" alt=""><figcaption><p>Compute - Rank input</p></figcaption></figure>

**Configuration**

```json
{
    "value_col": "sales",
    "order": "standard",
    "method": "asc",
    "group_by": [],
    "new_column_name": "sales_rank_asc"
}
```

**Output**

<figure><img src="https://1809014303-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZxYYf1KpgarKMgMsDCrw%2Fuploads%2Fgit-blob-bf41a7a7131b687256fc64f54c3d1ab8be2518d1%2Frank_output.png?alt=media" alt=""><figcaption><p>Compute - Rank output</p></figcaption></figure>

{% hint style="info" %}
There are 2 ranking methods available, that you will understand easily through those examples:

* `standard`: input = \[10, 20, 20, 20, 25, 25, 30] => ranking = \[1, 2, 2, 2, 5, 5, 6]
* `dense`: input = \[10, 20, 20, 20, 25, 25, 30] => ranking = \[1, 2, 2, 2, 3, 3, 4]

(The `dense` method is basically the same as the `standard` method, but rank always increases by 1 at most).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs-v3.toucantoco.com/data-management-in-datahub/datasets-in-toucan/preparing-data/overview-of-youprep-tm/compute/rank.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
