### Defining hierarchies

Hierarchies can be defined in a business view to allow users to drill report data up and down to particular groups on JReport Server. A hierarchy is defined as a hierarchy category holding one group of group objects sharing a hierarchical relationship, following the order from the highest level to the lowest. For example, these group objects can be added into one hierarchy group called Dates: Sales Year, Sales Quarter, Sales Month, and Sales Date. When any of these group fields are used for grouping data in a table, crosstab or chart, end users can use the context menu to drill up or down to the next level. You can create any number of hierarchies such as dates, times, geography, product types, and so on.

The group objects added in a hierarchy are just references to the real group objects and therefore cannot be edited.

To define hierarchies in a business view, you can take either of the following two ways:

#### Defining a data hierarchy in the Business View Editor

1. In the Catalog Browser resource tree, select the business view, right-click it and click Edit on the shortcut menu.
2. In the Business View Editor, select the business view or any category in the Business View panel, then,
   - Right-click and select Add Hierarchy from the shortcut menu.
   - Click Insert > Hierarchy on the menu bar.
   - Click the Insert Hierarchy button on the toolbar.
3. In the Add Hierarchy dialog, provide a name and click OK. The name should be unique among the hierarchies in the business view.
4. A blank hierarchy will be added to the business view resource tree. You can then add group objects into the hierarchy as a hierarchical group by dragging and dropping.
5. Drag a group object either from the resource tree in the Resource Objects panel or from the business view resource tree in the Business View panel and then drop it into the hierarchy. The inserted position depends on the dropped position:
   - When you drop on the hierarchy root node, the group object will be placed to the bottom level of the hierarchy.
   - When on an existing level, the group object will be placed below it.
   - When between two levels, the group object will be placed between them.

6. To adjust the order of the group objects in the hierarchy, make use of the or button. The higher the position is, the higher the level is.

7. To remove a group object from the hierarchy, select it, then right-click and select Remove from Hierarchy on the shortcut menu.

#### Adding a data hierarchy in the Data tab of the Catalog Browser

1. In the Catalog Browser resource tree, right-click a category in a business view and select Add Hierarchy from the shortcut menu.
2. Provide a name in the Add Hierarchy dialog and then click OK. The name should be unique among the hierarchies in the business view.
3. A hierarchy will be added in the business view.
4. Follow the steps 5 to 7 in the above section to define the hierarchy in the Business View Editor.

Tip: Hierarchies can be added into any category in a business view and it does not make any difference where it is placed. For easy look-over, you can put them under the root category.