

The Transactions table has a many-to-one relationship with the Nodes table. Suppose you have a Nodes table containing one row per node, with a ParentKey column that defines the parent of every node. Complex organizations that do not respect this constraint require more complex graphs, and mapping them to a parent-child hierarchy requires a normalization to a regular organization tree. One of the limitations of parent-child hierarchies is that each node must have a single parent. When this is not the native representation in the data source, a parent-child hierarchy can be useful to show an alternative custom grouping of original accounts, such as in balance sheet reclassification.Ĭompany organizational structures are often represented as parent-child hierarchies. Most profit and loss statements have a native parent-child hierarchy for representing the list of accounts. You can use the Parent-Child Hierarchies pattern any time you have a corresponding structure in your source data. You can avoid this behavior in Analysis Services Tabular by using the HideMemberIf property, and in Power Pivot by using the technique described in the complete pattern. If an intermediate node of the hierarchy has no children, you can still drill-down to an empty label, although this would result in a row of the pivot table with no description. You can browse a pivot table and navigate this hierarchy down to the third level. Figure 6 The Sum of Sales measure displays the total sales of all agents below the selected node in the hierarchy. You can navigate the resulting hierarchy in Excel as shown in Figure 6. Figure 5 The Hierarchy heading includes the calculated columns created to naturalize the hierarchy. You define the hierarchy in the diagram view of the data model shown in Figure 5. = PATH ( Nodes, Nodes )įigure 4 The Path column contains the result of the PATH functionĮach column that defines a level in the hierarchy uses the PATHITEM function to retrieve the proper value for that level, as shown in Figure 3. The Path column in Figure 4 provides this content using the special PATH function. You can create these columns in DAX by leveraging a hidden calculated column that provides a string with the complete path to reach the node in the current row of the table. Power Pivot and Analysis Services hierarchies have an intrinsic limit of 64 levels.įigure 3 shows the resulting table with the naturalized hierarchy.įigure 3 The naturalized hierarchy has one column for each level of the hierarchy. Otherwise, you have to estimate it, because this number cannot change dynamically. To create the right number of calculated columns, you must know in advance the maximum depth of the hierarchy. Your goal is to create one calculated column for each level of the hierarchy. Figure 2 The hierarchy has two branches-one with two levels and one with three levels. You might represent relationships between nodes using a tree structure, where all nodes without a parent are roots of a hierarchy tree, as shown in Figure 2. The Parent column specifies the direct report of each agent, as you see in Figure 1.įigure 1 Values in the Parent column reference the Name column. Suppose you have an Agents table containing sales figures for each agent.

The complete pattern also includes measures that improve the visualization of ragged hierarchies in Power Pivot.

DAX provides specific functions to naturalize a parent-child hierarchy using calculated columns. To obtain a browsable hierarchy in the data model, you have to naturalize a parent-child hierarchy. DAX does not directly support parent-child hierarchies.
