PATHLENGTH

The PATHLENGTH function returns the number of parents of the corresponding item, including itself.

Syntax

PATHLENGTH(
    path
)

Parameters
  • path: Text string resulting from applying the PATH function.
Returned value

The PATHLENGTH function returns an integer.

Additional Information

The returned result includes the item itself referenced by the path.

Examples

We start from the following table:

Functions of parents and children. Data table

This table contains worker identifiers and the hierarchical relationship between them. The scheme of this hierarchy is shown in the following figure:

Functions of parents and children. Hierarchy

Once the path of each employee is obtained, we can extract the number of superiors of each worker (including himself) with the following measure:

pathlength = PATHLENGTH(Employees[path])

PATHLENGTH function. Example of use

We can confirm how worker 112 -located at the top of the hierarchy- has a path of length 1 (only him), while workers 117, 221 and 81, for example, have a path of length 5 (the maximum in the structure).

Category
Parent and child
Submitted by admin on Thu, 01/31/2019 - 09:54