The PATHCONTAINS function returns the logical value True if the specified element exists in the path.
PATHCONTAINS(
path,
item
)
- path: Text string generated with the PATH function.
- item: Element to find in the text string path.
The PATHCONTAINS function returns a Boolean.
If item is a number, it is converted to text before searching. If the conversion fails, the PATHCONTAINS function returns an error.
We start from the following table:
This table contains worker identifiers and the hierarchical relationship between them. The scheme of this hierarchy is shown in the following figure:
Once the path of each employee has been extracted, we can check which ones have employee 162 as their hierarchical superior with the following DAX expression:
contains_162 = PATHCONTAINS(Employees[path], "162")
Since the path of an element includes the identifier of the element itself, the employee with identifier 162 also appears with the label True in the created column.