PATHLENGTH DAX function in Power BI

The PATHLENGTH DAX function returns the number of parents to the specified item in a given PATH result, including self.

DAX Syntax PATHLENGTH(path)

The function parameter path is a text expression resulting from evaluation of a PATH function.

Return value: The number of items that are parents to the specified item in a given PATH result, including the specified item.

Example: The following example takes an employee ID as input to a PATH function and returns a list of the managers above that employee in the hierarchy. The PATHLENGTH function takes that result and counts the different levels of employees and managers, including the employee you started with.

DAX

HierarchyPath = 
    PATH(
        Employees[EmployeeID], 
        Employees[ManagerID]
    )    

The output of the above code is shown below:

PATHLENGTH DAX Function in Power BI

DAX

PATHLENGTH Column = PATHLENGTH(Employees[HierarchyPath]) 

The output of the above code is shown below:

PATHLENGTH DAX Function in Power BI