Home » DAX » DAX Parent & Child – PATHCONTAINS Function

DAX Parent & Child – PATHCONTAINS Function

PATHCONTAINS DAX Power BI

PATHCONTAINS DAX function is used to check the specified items existing within the specified path.

It returns TRUE if the specified item exists within the specified path. This function is categorized under the Parent and child function.

Refer similar post:- PATH DAX, PATHITEM DAX, PATHLENGTH DAX

Syntax:

PATHCONTAINS(<path>, <item>)




Description:

S no. Parameter Description
1 path A string created as the result of evaluating a PATH function.
2 item A text expression to look for in the path result.

Note:

  • It returns TRUE if item exists in path else FALSE.
  • if the value is an integer it automatically converted into string/text and then the function evaluated. If conversion fails then the function returns an error.
  • This function is not supported for use in Direct Query mode




So let’s start with an example, sample dataset format as below:

Table Name – EmployeeData

EmpId Dept EmpName Parent Id
1 Manager Sandeep Raturi
2 Team Lead Antonio Moreno 1
3 Team Lead Aria Cruz 1
4 Team Lead Dinesh Raturi 1
5 Developer Matt 4
6 Developer Jhon 4
7 Developer Jacobs 2
8 Developer David 3
9 IT Support Jack 2

In above dataset we have EmpId, Dept, EmpName & Parent Id columns, and Parent Id column contains Employee manager Id.

Let’s try to find item(Empid 4) is exist or not within the specified path, 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 Path contains and write below DAX code.

Path Contains = PATHCONTAINS(PATH(EmployeeData[EmpId],EmployeeData[Parent Id]),4)

See the output:

PATHCONTAINS DAX

PATHCONTAINS DAX

You can see in above screenshot where the path column contains Id 4, it is showing true; otherwise false.

Refer this- How to get manager name from specified path?

Refer similar post:- PATH DAX, PATHITEM DAX, PATHLENGTH DAX




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.

Leave a Reply