Parent-Child Hierarchies0%

Parent-Child Hierarchies

Beginner12 min read•Updated: Jul 11, 2026
Study MaterialsCheatsheet

Parent-Child Hierarchies in DAX: PATH, PATHITEM & Organizational Trees

In organizational management, employee reporting structures, and general ledger chart of accounts, data is frequently organized in Parent-Child Hierarchies:

  • An employee reports to a Manager.
  • That Manager reports to a Director.
  • The Director reports to a Vice President.
  • The Vice President reports to the CEO.

Unlike fixed-depth product hierarchies (Category $\to$ SubCategory $\to$ Product), parent-child hierarchies have uneven and variable depth (one branch may have 3 levels, while another has 7 levels).


1. The DAX PATH Functions

DAX provides specialized functions to unravel recursive parent-child structures into linear, navigable dimensions:

FunctionPurposeSyntax
PATHGenerates a delimited text string tracing the lineage from top root to current node.PATH(IDColumn, ParentIDColumn)
PATHLENGTHReturns the depth (level count) of the current node in the hierarchy tree.PATHLENGTH(PathColumn)
PATHITEMExtracts the specific ancestor ID at a designated level of the path.PATHITEM(PathColumn, Position, [Type])
PATHCONTAINSChecks whether a specific ancestor ID exists anywhere within the path (ideal for security!).PATHCONTAINS(PathColumn, ManagerID)

2. Step-by-Step Parent-Child Flattening

Consider Dim_Employee with EmployeeID and ManagerID:

Output
EmployeeID | EmployeeName | ManagerID
---------------------------------------
1 | Satya (CEO) | BLANK
2 | Scott (EVP) | 1
3 | Julia (CVP) | 2
4 | Aarav (Eng) | 3

Step 1: Create the Hierarchy Path Column

DAX
EmployeePath = PATH(Dim_Employee[EmployeeID], Dim_Employee[ManagerID])
-- Result for Aarav: "1|2|3|4"

Step 2: Extract Leveled Hierarchy Columns

DAX
Level_1_Executive =
LOOKUPVALUE(
Dim_Employee[EmployeeName],
Dim_Employee[EmployeeID],
PATHITEM(Dim_Employee[EmployeePath], 1, INTEGER)
)
 
Level_2_VP =
LOOKUPVALUE(
Dim_Employee[EmployeeName],
Dim_Employee[EmployeeID],
PATHITEM(Dim_Employee[EmployeePath], 2, INTEGER)
)
 
Level_3_Director =
LOOKUPVALUE(
Dim_Employee[EmployeeName],
Dim_Employee[EmployeeID],
PATHITEM(Dim_Employee[EmployeePath], 3, INTEGER)
)

Now you can drag Level_1_Executive, Level_2_VP, and Level_3_Director into a standard Matrix visual to render a clean, drillable organizational tree!


Interactive Quiz

Multiple Choice Questions

Question 1
What DAX function converts a recursive Parent-Child relationship (e.g., EmployeeID and ManagerID) into a delimited string tracing the full lineage path?
Question 2
What delimiter does the DAX PATH function use internally to separate ancestor IDs?
Question 3
How do you determine the depth level of an employee in an organizational hierarchy tree?
Question 4
Which function checks whether a specific manager exists anywhere in an employee's management chain for organizational Row-Level Security?
Question 5
Why is flattening parent-child hierarchies into discrete columns (Level 1, Level 2, Level 3) necessary for Power BI visuals?

Next Lesson

Row-Level Security (Advanced)

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext