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

# Virtual hierarchies

> How to configure virtual hierarchies in the Atoti Java SDK, including memory trade-offs, custom member-name parsers, and MDX limitations.

> [!NOTE]
>
> For a conceptual understanding of virtual hierarchies, see [Virtual hierarchies](https://docs.activeviam.com/concepts/performance/virtual-hierarchies.md).

A virtual hierarchy stores no members in the cube at commit time. This reduces memory usage and accelerates server startup for hierarchies with large member counts, such as a trade ID hierarchy.

## What is the difference between a virtual and a non-virtual hierarchy?

A non-virtual hierarchy collects all members from the database and stores them in the cube. For hierarchies with millions of members, this increases memory usage and loading time significantly.

A virtual hierarchy defers member resolution to query time. Members are not stored in the cube, so the hierarchy has a smaller memory footprint and faster commit times. However, some operations that require pre-aggregated member data must fall back to database queries. For example, retrieving all the members of a level of a virtual hierarchy, or searching for a specific member, triggers a database query.

## How to declare a virtual hierarchy

To mark a hierarchy as virtual, call `virtual()` when you build the hierarchy.

By default, Atoti resolves hierarchy level members whose type is numeric or string. For other level types, such as [dates](https://docs.activeviam.com/engine/java-sdk/6.2/core_features/dates.md), provide a custom member-name-to-discriminator parser.

Set the custom parser through the level builder using the `withMemberNameParserPluginKey` method.

The following snippet shows a complete virtual hierarchy configuration:

```java theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
.withDimension("Virtual")
.withHierarchyOfSameName()
.virtual()
.withLevel("Virtual currency", "currency")
.withLevel("Virtual date", "tradeDate")
.withMemberNameParserPluginKey(dateParserPluginKey);
```

## What are the limitations of virtual hierarchies?

Virtual hierarchies do not support the full set of MDX operations available to non-virtual hierarchies.

* Member navigation between hierarchy members, as performed in `Lead` and `Lag` measures, is not supported.
* MDX expressions that describe a member expression must provide the full member path.
* MDX expressions that include a virtual hierarchy and do not include the `NON EMPTY` keyword trigger a database query.
* A virtual hierarchy cannot be a slicing hierarchy.
* A level of a virtual hierarchy cannot be a [distributing level](https://docs.activeviam.com/engine/java-sdk/6.2/distributed/distributed_intro.md#distributing-levels). A data cube whose distributing level belongs to a virtual hierarchy refuses to join the query cube and stops its distribution.

## Which visualization tools are compatible?

Atoti UI is the recommended visualization tool for virtual hierarchies. Most Excel functionalities are also supported.
