atoti.query.cube module

class atoti.query.cube.QueryCube(_name, _hierarchies, _measures, _session)

Bases: atoti._base._base_cube.BaseCube[atoti.query.hierarchies.QueryHierarchies, atoti.query.levels.QueryLevels, atoti.query.measures.QueryMeasures]

Query cube.

property levels

Levels of the cube.

Return type

QueryLevels

query(*measures, condition=None, include_totals=False, levels=None, scenario='Base', timeout=30, **kwargs)

Query the cube to retrieve the value of the passed measures on the given levels.

In JupyterLab with the atoti-jupyterlab plugin installed, query results can be converted to interactive widgets with the Convert to Widget Below action available in the command palette or by right clicking on the representation of the returned Dataframe.

Parameters
  • measures (QueryMeasure) – The measures to query. If None, all the measures are queried.

  • condition (Union[LevelCondition, MultiCondition, None]) –

    The filtering condition. Only conditions on level equality with a string are supported. For instance:

    • lvl["Country"] == "France"

    • (lvl["Country"] == "USA") & (lvl["Currency"] == "USD")

    • h["Geography"].isin(("Asia",), ("Europe", "France"))

  • include_totals (bool) – Whether the returned DataFrame should include the grand total and subtotals. Totals can be useful but they make the DataFrame harder to work with since its index will have some empty values.

  • levels (Union[QueryLevel, Sequence[QueryLevel], None]) – The levels to split on. If None, the value of the measures at the top of the cube is returned.

  • scenario (str) – The scenario to query.

  • timeout (int) – The query timeout in seconds.

Return type

QueryResult