How does the PATHLENGTH function (DAX) work?

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

PATHLENGTH Formula Syntax


How do you use the PATHLENGTH function?

You can use PathLength Function to find out the count of levels for each row. This function gets the result of Path function as the input.

Related Blog Posts

Related Support Forum Posts

Eplace the empty string to a blank value
Parent Child Hierachy

Dax Calculation question

Considerations when using the PATHLENGTH function

Example if the values in the PATHLENGTH column show seven levels in the hierarchy. To create the parent-child hierarchy, you must create a calculated column for each level of the hierarchy. DAX provides PATHITEM and PATHITEMREVERSE functions that return the value on a given level from the Path string. The PATHITEM function returns the item/value for a given level from the beginning of the string, whereas the PATHITEMREVERSE functions returns the item/value for a given level from the end of the string.

Related Video Tutorials

Formula examples using the PATHLENGTH function

=PATHLENGTH(PATH(Employee[EmployeeKey], Employee[ParentEmployeeKey]))

= PATHLENGTH(OrganizationHierarchy[Hierarchy])[/dax]

= PATHLENGTH(DimEmployee[Path])

Related Course Modules



Download our comprehensive DAX Formula Reference Guide as perfect companion as you learn how to use DAX formulas within Power BI.

Download DAX Formulas Reference Guide
Download DAX Formula Reference Guide