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

# Dimension.default_hierarchy

<span id="atoti.Dimension.default_hierarchy" />

> *property* Dimension.default\_hierarchy: [Hierarchy](./atoti.Hierarchy#atoti.Hierarchy)

The default hierarchy of the dimension.

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

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> 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_name == table.name
>>> dimension = cube.dimensions["Sales"]
```

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

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> dimension.default_hierarchy.name
'Product'
```

The default hierarchy can be changed:

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> dimension.default_hierarchy = h["Shop"]
>>> dimension.default_hierarchy.name
'Shop'
```

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

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> del h["Shop"]
>>> dimension.default_hierarchy.name
'Product'
```

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

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> h["Product"].dimension_name = "Product"
>>> dimension.default_hierarchy.name
'Customer'
```

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

```pycon theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
>>> cube.dimensions["Product"].default_hierarchy.name
'Product'
```
