atoti.level module#

class atoti.Level#

Level of a atoti.Hierarchy.

A level is a sub category of a hierarchy. Levels have a specific order with a parent-child relationship.

In a Pivot Table, a single-level hierarchy will be displayed as a flat attribute while a multi-level hierarchy will display the first level and allow users to expand each member against the next level and display sub totals.

For example, a Geography hierarchy can have a Continent as the top level where Continent expands to Country which in turns expands to the leaf level: City.

property data_type: Literal['boolean', 'double', 'double[]', 'float', 'float[]', 'int', 'int[]', 'LocalDate', 'LocalDateTime', 'LocalTime', 'long', 'long[]', 'Object', 'Object[]', 'String', 'ZonedDateTime']#

Type of the level members.

Return type

Literal[‘boolean’, ‘double’, ‘double[]’, ‘float’, ‘float[]’, ‘int’, ‘int[]’, ‘LocalDate’, ‘LocalDateTime’, ‘LocalTime’, ‘long’, ‘long[]’, ‘Object’, ‘Object[]’, ‘String’, ‘ZonedDateTime’]

property dimension: str#

Name of the dimension holding the level.

Return type


property hierarchy: str#

Name of the hierarchy holding the level.

Return type



Return a condition to check that the level is on one of the given members.

level.isin(a, b) is equivalent to (level == a) OR (level == b).


members – One or more members on which the level should be.


>>> df = pd.DataFrame(
...     columns=["City", "Price"],
...     data=[
...         ("Berlin", 150.0),
...         ("London", 240.0),
...         ("New York", 270.0),
...         ("Paris", 200.0),
...     ],
... )
>>> table = session.read_pandas(
...     df, keys=["City"], table_name="isin example"
... )
>>> cube = session.create_cube(table)
>>> l, m = cube.levels, cube.measures
>>> m["Price.SUM in London and Paris"] = tt.filter(
...     m["Price.SUM"], l["City"].isin("London", "Paris")
... )
>>> cube.query(
...     m["Price.SUM"],
...     m["Price.SUM in London and Paris"],
...     levels=[l["City"]],
... )
         Price.SUM Price.SUM in London and Paris
Berlin      150.00
London      240.00                        240.00
New York    270.00
Paris       200.00                        200.00
property name: str#

Name of the level.

Return type


property order: Union[atoti.order.custom_order.CustomOrder, atoti.order.natural_order.NaturalOrder]#

Order in which to sort the level’s members.

Defaults to ascending atoti.NaturalOrder.

Return type

Union[CustomOrder, NaturalOrder]