> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# n_greatest()

<span id="atoti.array.n_greatest" />

> atoti.array.n\_greatest(<br />
>     *measure*: VariableMeasureConvertible,<br />
>     /,<br />
>     *n*: PositiveInt | VariableMeasureConvertible,<br />
> ) → MeasureDefinition

Return an array measure containing the *n* greatest elements of the passed array measure.

The values in the returned array are not sorted, use [`atoti.array.sort()`](./atoti.array.sort#atoti.array.sort) to sort them.

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> pnl_table = session.read_csv(
...     TEST_RESOURCES_PATH / "csv" / "pnl.csv",
...     array_separator=";",
...     keys={"Continent", "Country"},
...     table_name="PnL",
... )
>>> cube = session.create_cube(pnl_table)
>>> l, m = cube.levels, cube.measures
>>> m["Top 3"] = tt.array.n_greatest(m["PnL.SUM"], n=3)
>>> cube.query(m["PnL.SUM"], m["Top 3"])
                          PnL.SUM                                    Top 3
0  doubleVector[10]{-20.163, ...}  doubleVector[3]{9.259999999999998, ...}
```

### Parameters

<h4 id="atoti.array.n_greatest.measure">
  *measure*
</h4>

> VariableMeasureConvertible

<h4 id="atoti.array.n_greatest.n">
  *n*
</h4>

> PositiveInt | VariableMeasureConvertible
