# 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**](https://docs.cascade.io/cascade/functions-and-expressions/building-expressions/guide-to-window-functions)**,** 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/>" %}
