In organizational management, employee reporting structures, and general ledger chart of accounts, data is frequently organized in Parent-Child Hierarchies:
Unlike fixed-depth product hierarchies (Category → SubCategory → Product), parent-child hierarchies have uneven and variable depth (one branch may have 3 levels, while another has 7 levels).
DAX provides specialized functions to unravel recursive parent-child structures into linear, navigable dimensions:
| Function | Purpose | Syntax |
|---|---|---|
PATH | Generates a delimited text string tracing the lineage from top root to current node. | PATH(IDColumn, ParentIDColumn) |
PATHLENGTH | Returns the depth (level count) of the current node in the hierarchy tree. | PATHLENGTH(PathColumn) |
PATHITEM | Extracts the specific ancestor ID at a designated level of the path. | PATHITEM(PathColumn, Position, [Type]) |
PATHCONTAINS | Checks whether a specific ancestor ID exists anywhere within the path (ideal for security!). | PATHCONTAINS(PathColumn, ManagerID) |
Consider Dim_Employee with EmployeeID and ManagerID:
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!
PATH function use internally to separate ancestor IDs?Level 1, Level 2, Level 3) necessary for Power BI visuals?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Advanced Time Intelligence | Row-Level Security (Advanced) |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Combine 15 complete courses, 150 chapters, 541 topics, live SQL/Power BI/Tableau dashboards, and Scikit-Learn capstones at MSK Institute Shikohabad or Live Online.