PATHITEM DAX function returns the item at the specified position from a string resulting from evaluation of a PATH function. Positions are counted from left to right and it comes under Parent and child functions.
PATHITEM(<path>, <position>, <type>)
|1||path||A text string in the form of the results of a PATH function.|
|2||position||An integer expression with the position of the item to be returned.|
|3||type||(Optional)An enumeration that defines the data type of the result:
0-Results are returned with the data type text. (default).
1- Results are returned as integers.
- This function can be used to return a specific level from a hierarchy returned by a PATH function.
- This function does not support the Direct Query mode.
So let’s start with an example, sample dataset format as below:
Table Name – EmployeeData
|2||Team Lead||Antonio Moreno||1|
|3||Team Lead||Aria Cruz||1|
|4||Team Lead||Dinesh Raturi||1|
In above dataset we have EmpId, Dept, EmpName & Parent Id columns, and Parent Id column contains Employee manager Id.
Follow these steps-
Step-1: Create a new calculated column for PATH and write below DAX code.
Path = PATH(EmployeeData[EmpId],EmployeeData[Parent Id])
Step-2: Create another calculated column for PATHITEM and write below DAX code.
PathItems(Level-2 Emp)= PATHITEM(PATH(EmployeeData[EmpId], EmployeeData[Parent Id]),2,1)
See the output:
You can see in above screenshot, we have provided second position to fetch employee manager that are at level 2.
If you want to see level 3 positions –
PathItems(Level-3 Emp) = PATHITEM(PATH(EmployeeData[EmpId], EmployeeData[Parent Id]),3,1)
See the final output-
Refer this- How to get manager name from specified path?
Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our Contact form , we will revert to you asap.