Power BI DAX Tutorial: Handling Parent-Child Hierarchies with PATH, PATHITEM, and LOOKUPVALUE
Table of Contents
Introduction
Parent-child hierarchies are common in real-world data models, especially when working with organizational structures such as employee reporting lines, account hierarchies, or product categories. In Power BI, these hierarchies cannot be handled easily using standard relationships.
To solve this challenge, Power BI provides specialized DAX functions like PATH(), PATHITEM(), PATHLENGTH(), and LOOKUPVALUE(). These functions allow you to traverse hierarchical data, create fixed hierarchy levels, and display them correctly in visuals such as matrix tables.
In this blog, you will learn how to use functions to build and navigate parent-child hierarchies step by step. This guide is designed for beginners who want a clear and practical understanding of hierarchical modeling in Power BI.
Want to learn more about Parent-child hierarchies? Check out our blog: Power BI DAX Tutorial Analyzing Parent-Child Hierarchies and Sales Using DAX
What is PATH() in Power BI?
PATH() in Power BI is a DAX function used to handle parent-child hierarchies by creating a traversal path from child to parent.
Using Path functions to traverse hierarchy
PATH() is a function in Power BI that is specifically created to handle parent-child hierarchies. It returns the path that needs to be traversed from the child to the parent.
To create the path column:
1. Right-click on the Employee table in the Fields pane
2. Click on New column.
Column tools open.
3. Type the following formula in the formula bar and press Enter.
4. Click on the Datatab in the left ribbon.
5. Click on the Employeetable in the Fields pane.
Notice the Path for Sam Furimo, it shows that you need to traverse from Sam Furimo, Nick Treloar, Maryam Hussaini, and Ali Noorani.
The column for path itself is not useful, it is a hidden column use to create levels in a parent-child hierarchy.
Creating Levels
In order to fix the parent-child hierarchy in DAX, you will need to fix the maximum number of levels allowed.
Using PATHITEM()
PATHITEM() searches the Path column and returns the key present at the Nth position of the path.
Using LOOKUPVALUE()
The function is used to the return the name of the Employee whose Employee ID matches with the searched value by PATHITEM()
To create the Level 1 column:
1. Right-click on the Employee table in the Fields
2. Click on New column.
Column tools open.
3. Type the following formula in the formula bar and press Enter.
In the expression above:
- The PATHITEM() is use to return the Employee ID,which is at the 1st position
of the Path.
- The LOOKUPVALUE() searches for the Employee ID in the Employee ID column,and when the results match with that of PATHITEM(), it returns the corresponding Employee Name from the Employee[Names] column.
Now that you have created the column for Level 1, you will do similar calculations for all other columns. However, you will additionally need to check if the path length is greater than 2 using the PATHLENGTH() function.
To create the remaining levels:
4. Right-click on the Employee table in the Fields
5. Click on New column.
Column tools open.
6. Type the following formula in the formula bar and press Enter.
In the expression above:
- First ofall, the PATHLENGTH() is evaluated.
- If the PATHLENGTH() is greater than 2,then it means that the current filtering is at the second level of the hierarchy, and LOOKUPVALUE() is performed.
- Otherwise,the employee name at the last level is returned.
7. Right-clickon the Employee table in the Fields pane
8. Click on New column.
Column tools open.
9. Type the following formula in the formula bar and press Enter.
10. Right-click on the Employee table in the Fields pane
11. Click on New column.
Column tools open.
12. Type the following formula in the formula bar and press Enter.
13. Click on the Datatab in the left
14. Click on the Employeetable in the Fields pane
15. Click on the matrix visual in the visualization pane.
16. Drag and drop Level 1, Level 2, Level 3 and Level 4 columns from the Employee table to the rows.
A hierarchy will be detected by Power BI.
17. Drag and drop SalesAmount from the Salestable to the Values.
Notice that Ali Noorani is shown as the child for himself; this is not what you want.
Finding Maximum Depths
In this exercise, you will learn how to hide the parent member from the hierarchy. This involves 2 logical steps:
- Understand the hierarchicallevel that you are browsing on.
- Understand which member you want to hide.
So you will have to hide the node if the browsing of the hierarchy exceeds the depth of the node. To compute the depth of a node:
1. Right-clickon the Employee table in the Fields pane
2. Click on New column.
Column tools open.
3. Type the following formula in the formula bar and press Enter.
4. Click on the Datatab in the left ribbon
5. Click on Employee table in the Fields pane
Notice that Ali Noorani has a node depth of 1. Whereas Jack, Jones has a node depth of 2 because he is reporting to Ali.
Determining Browsing Levels
So far you have learned how to find the depth of the node. However, you have still not found a way to learn the level that you are browsing on.
To compute the depth of a node:
1. Right-clickon the Employee table in the Fields pane
2. Click on New measure.
Measure tools open.
3. Type the following formula in the formula bar and press Enter.
4. Drag and drop Maximum Node Depth (CM) from the Employeetable to the Values.
Notice that at the topmost level, Ali Noorani has four employees reporting to him. However, at the lower level, the maximum depth for Ali Noorani is 1 because there are no further reporting levels.
Let’s browse further to find the browsing depth.
5. Right-click on the Employee table in the Fields pane
6. Click on New measure.
Measure tools open.
7. Type the following formula in the formula bar and press Enter.
In the expression above:
- The ISINSCOPE() checks the level of current filter context.
- As aresult, all the TRUE values are counted.
8. Drag and drop Browsing Depth (CM) from the Employeetable to the Values.
Conclusion
Handling parent-child hierarchies is an essential skill for building professional Power BI reports. By using DAX functions such as PATH(), PATHITEM(), PATHLENGTH(), LOOKUPVALUE(), and ISINSCOPE(), you can transform complex hierarchical data into clean, readable, and interactive visuals.
With these concepts in place, you can confidently model organizational charts, reporting structures, and other parent-child datasets in Power BI. Mastering PATH functions not only improves report accuracy but also enhances performance and user experience in your Power BI solutions.
Want to learn more about DAX? Check out our blog: Learn How to Write DAX Queries in DAX Studio Using Query Builder
FAQs
A parent-child hierarchy in Power BI is a data structure where rows in the same table reference each other, such as employees reporting to managers or accounts grouped under parent accounts. Each record has both a unique ID and a parent ID.
PATHITEM() extracts a specific element from the hierarchy path created by PATH(). It is commonly used to create fixed hierarchy levels such as Level 1, Level 2, Level 3, and so on.
PATHITEM() returns an ID, not a readable name. LOOKUPVALUE() is used to convert that ID into a meaningful value, such as an employee name, by matching it with the appropriate column.
PATHLENGTH() returns the total number of levels in a hierarchy path. It is used to prevent errors and ensure that hierarchy levels are displayed only when they exist.
Further Learning and Resources
For more detailed learning and advanced Power BI training, go to
- Power BI Advanced Training Course.
- Power BI Report Design
- Power BI Essentials
- Power BI DAX Essentials
- Power BI Service Course
We offer comprehensive courses across major regions, including:







