# Rank

Create a ranking of values in a column.

## Parameters

| Name               | Type            | Description                                                                                                                                                                                                   | Is Optional |
| ------------------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| rank\_columns      | column\_list    | The column or expression to order (rank) by                                                                                                                                                                   |             |
| partition\_by      | column\_list    | The column or expression to partition the window by. Accepts .                                                                                                                                                | True        |
| order              | sort\_direction | Instruction on how to order the rank\_column. Accepts , but defaults to ASC. ASC = Ascending DESC = Descending                                                                                                | True        |
| rank\_type         | value           | Type of ranking \[ \| dense \| percent \| unique ]. Accepts . = ANSI SQL rank function dense = ANSI SQL dense\_rank function percent = ANSI SQL percent\_rank function unique = ANSI SQL row\_number function | True        |
| qualify\_filter    | value           | A filter to apply to the ranked column. Accepts .                                                                                                                                                             | True        |
| alias              | string          | Name of the output column containing rankings                                                                                                                                                                 | True        |
| overwrite\_columns | boolean         | Optional: if true, the columns passed in 'rank\_columns' will be dropped from the output                                                                                                                      | True        |

## Example

```python
#Return the 5 highest temperatures per date:
ds = rasgo.get.dataset(dataset_id)

ds2 = ds.rank(rank_columns=['DS_DAILY_HIGH_TEMP'],
      partition_by=['DATE'],
      ORDER='DESC',
      RANK_TYPE='unique',
      QUALIFY_FILTER='>=5'
})

ds2.preview()

```

## Source Code

{% embed url="<https://github.com/rasgointelligence/RasgoTransforms/blob/main/rasgotransforms/rasgotransforms/transforms/rank/rank.sql>" %}


---

# 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.rasgoml.com/rasgo-docs/rasgo-0.1/all-transforms/rank.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.
