Forum Discussion
Ned help with Path DAX
I am working on a hierarchy table where each row has an EmployeeID and a ParentID. I used the PATH function to build the full chain for every employee. Now I need to check if a specific manager exists anywhere inside that path. What is the right way to use PATHCONTAINS for this, and how do I return a flag when the manager is part of the chain?
To check if a specific manager exists in an employee's PATH chain using DAX, use the PATHCONTAINS function. It returns TRUE if the manager's EmployeeID is anywhere in the PATH string.
Example measure or calculated column:
ManagerInPathFlag = IF ( PATHCONTAINS(EmployeeTable[Path], ManagerID), 1, 0 )EmployeeTable[Path] is the column created by the PATH function.
ManagerID is the specific manager's ID you want to check within the path.
This flags rows with 1 when the manager appears in the hierarchy chain and 0 otherwise.
1 Reply
- Shubham_rai955Super User
To check if a specific manager exists in an employee's PATH chain using DAX, use the PATHCONTAINS function. It returns TRUE if the manager's EmployeeID is anywhere in the PATH string.
Example measure or calculated column:
ManagerInPathFlag = IF ( PATHCONTAINS(EmployeeTable[Path], ManagerID), 1, 0 )EmployeeTable[Path] is the column created by the PATH function.
ManagerID is the specific manager's ID you want to check within the path.
This flags rows with 1 when the manager appears in the hierarchy chain and 0 otherwise.