> For the complete documentation index, see [llms.txt](https://docs.cascade.io/cascade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cascade.io/cascade/functions-and-expressions/functions/table/rankby.md).

# RANKBY

RANKBY(`column`, `partition` , `[ascending]`, `[rank_type]`)

Ranks the values within a `column` when grouped by unique values within a `partition column`

{% hint style="info" %}
RANKBY() is a [**window function**](/cascade/functions-and-expressions/building-expressions/guide-to-window-functions.md)**,** which perfoms like RANK() except partitioned by the values of a separate column
{% endhint %}

### Arguments

| Argument           | Description                                                                                                                                                                                                                                                                                                                      |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `column`           | Column to evaluate in ranking                                                                                                                                                                                                                                                                                                    |
| `partition column` | Column containing unique values.                                                                                                                                                                                                                                                                                                 |
| `[ascending]`      | <p>Optional, defaults to true. Order in which elements should be sorted.</p><ul><li>1: Ascending</li><li>0: Descending</li></ul>                                                                                                                                                                                                 |
| `[rank_type]`      | <p>Optional, defaults to "average". Option for how to rank the group of elements that have the same value.</p><ul><li>"average": average rank of the group</li><li>"min": lowest rank of the group</li><li>"max": highest rank of the group</li><li>"dense": like "min", but rank always increases by 1 between groups</li></ul> |

### Outputs

Outputs column of values containing rank of each value

### Example

{% embed url="<https://datawrapper.dwcdn.net/c7mqg/1/>" %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cascade.io/cascade/functions-and-expressions/functions/table/rankby.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
