DAX Function Guide

PATHLENGTH
Empty image or helper icon

Sam McKay

CEO & Founder

How does the PATHLENGTH work?
The PATHLENGTH function (DAX) returns the number of parents to the specified item in a given PATH result, including self.
PATHLENGTH Formula Syntax

PATHLENGTH(
     <path>
)

How do you use the PATHLENGTH?

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

Loading

Considerations when using the PATHLENGTH?

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

Loading

Formula examples using the PATHLENGTH

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

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

= PATHLENGTH(DimEmployee[Path])

Related Courses

Loading