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

# max_member()

<span id="atoti.agg.max_member" />

> atoti.agg.max\_member(<br />
>     *measure*: VariableMeasureConvertible,<br />
>     /,<br />
>     *level*: [Level](./atoti.Level#atoti.Level),<br />
> ) → MeasureDefinition

Return a measure equal to the member maximizing the passed measure on the given level.

When multiple members maximize the passed measure, the first one
(according to the order of the given level) is returned.

### Parameters

<h4 id="atoti.agg.max_member.measure">
  *measure*
</h4>

The measure to maximize.

<h4 id="atoti.agg.max_member.level">
  *level*
</h4>

The level on which the maximizing member is searched for.

***

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> df = pd.DataFrame(
...     columns=["Continent", "City", "Price"],
...     data=[
...         ("Europe", "Paris", 200.0),
...         ("Europe", "Berlin", 150.0),
...         ("Europe", "London", 240.0),
...         ("North America", "New York", 270.0),
...     ],
... )
>>> table = session.read_pandas(
...     df,
...     table_name="City price table",
... )
>>> table.head()
       Continent      City  Price
0         Europe     Paris  200.0
1         Europe    Berlin  150.0
2         Europe    London  240.0
3  North America  New York  270.0
>>> cube = session.create_cube(table, mode="manual")
>>> h, l, m = cube.hierarchies, cube.levels, cube.measures
>>> h["Geography"] = [table["Continent"], table["City"]]
>>> m["Price"] = tt.agg.single_value(table["Price"])
    >>> m["City with maximum price"] = tt.agg.max_member(m["Price"], l["City"])
```

> At the given level, the measure is equal to the current member of the City level:

> ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
> >>> cube.query(m["City with maximum price"], levels=[l["City"]])
>                        City with maximum price
> Continent     City
> Europe        Berlin                    Berlin
>               London                    London
>               Paris                      Paris
> North America New York                New York
> ```

> At a level above it, the measure is equal to the city of each continent with the maximum price:

> ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
> >>> cube.query(m["City with maximum price"], levels=[l["Continent"]])
>               City with maximum price
> Continent
> Europe                         London
> North America                New York
> ```

> At the top level, the measure is equal to the city with the maximum price across all continents:

> ```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
> >>> cube.query(m["City with maximum price"])
>   City with maximum price
> 0                New York
> ```
