atoti.Hierarchy.dimension_default#

property Hierarchy.dimension_default: bool#

Whether the hierarchy is the default in its dimension or not.

Some UIs support clicking on a dimension (or drag and dropping it) as a shortcut to add its default hierarchy to a widget.

Example

>>> table = session.create_table(
...     "Sales",
...     data_types={
...         "Product": "String",
...         "Shop": "String",
...         "Customer": "String",
...         "Date": "LocalDate",
...     },
... )
>>> cube = session.create_cube(table, mode="manual")
>>> h = cube.hierarchies
>>> for column_name in table:
...     h[column_name] = [table[column_name]]
...     assert h[column_name].dimension == table.name

By default, the default hierarchy of a dimension is the first created one:

>>> h["Product"].dimension_default
True
>>> h["Shop"].dimension_default
False
>>> h["Customer"].dimension_default
False
>>> h["Date"].dimension_default
False

There can only be one default hierarchy per dimension:

>>> h["Shop"].dimension_default = True
>>> h["Product"].dimension_default
False
>>> h["Shop"].dimension_default
True
>>> h["Customer"].dimension_default
False
>>> h["Date"].dimension_default
False

When the default hierarchy is deleted, the first created remaining one becomes the default:

>>> del h["Shop"]
>>> h["Product"].dimension_default
True
>>> h["Customer"].dimension_default
False
>>> h["Date"].dimension_default
False

The same thing occurs if the default hierarchy is moved to another dimension:

>>> h["Product"].dimension = "Product"
>>> h["Customer"].dimension_default
True
>>> h["Date"].dimension_default
False

Since Product is the first created hierarchy of the newly created dimension, it is the default one there:

>>> h["Product"].dimension_default
True