PATHLENGTH DAX function is used to counts the number of parents to the specified item in a given PATH result, including self.
This function is categorized under the Parent and child function.
Refer similar post:- PATH DAX, PATHCONTAINS DAX, PATHITEM DAX
Syntax:
PATHLENGTH(<path>)
Description:
S no. | Parameter | Description |
1 | path | A text expression resulting from evaluation of a PATH function. |
Note:
This function does not support Direct Query mode.
So let’s start with an example, sample dataset format as below:
Table Name – EmployeeData
EmpId | Dept | EmpName | Parent Id |
1 | Manager | Sandeep Raturi | |
2 | Team Lead | Antonio Moreno | 1 |
3 | Team Lead | Aria Cruz | 1 |
4 | Team Lead | Dinesh Raturi | 1 |
5 | Developer | Matt | 4 |
6 | Developer | Jhon | 4 |
7 | Developer | Jacobs | 2 |
8 | Developer | David | 3 |
9 | IT Support | Jack | 2 |
In above dataset we have EmpId, Dept, EmpName & Parent Id columns, and Parent Id column contains Employee manager Id.
Follow these steps in order to counts the number of parents(levels) to the specified item in a given PATH-
Step-1: Create a new calculated column for PATH and write below DAX code.
Path = PATH(EmployeeData[EmpId],EmployeeData[Parent Id])
Step-2: Create another calculated column for PATHLENGTH and write below DAX code.
PathLength - Levels = PATHLENGTH(PATH(EmployeeData[EmpId],EmployeeData[Parent Id]))
See the output

DAX PATHLENGTH in Power BI
Refer similar post:- PATH DAX, PATHCONTAINS DAX, PATHITEM DAX
Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our Contact form , we will revert to you asap.