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