PATHCONTAINS
Whether a PATH text holds a key.
Group: Parent and child. Compatible with DAX.
Syntax
PATHCONTAINS ( <path>, <item> )
| Parameter | Type | Description |
|---|---|---|
path | Text | A path as PATH writes it: keys separated by |. |
item | Value | The key to look for; a number is turned into text first. |
Returns
Boolean. TRUE when the key is one of the path's keys, FALSE when not.
Remarks
- Only whole keys match: 0 is not found in 1|10|11, although 10 holds a 0.
- Keys are compared without regard to case, as OAX compares text: a is found in A|B.
- A blank path holds no key, not even an empty one:
PATHCONTAINS ( BLANK (), "" )is FALSE. - For a row's path, TRUE means the key is the row itself or one of the rows above it. That makes it the way to pick everything under a node of the tree (examples 2 and 3).
Examples
Keys in a path
EVALUATE
ROW (
"10", PATHCONTAINS ( "1|10|11", 10 ),
"20", PATHCONTAINS ( "1|10|11", 20 ),
"0", PATHCONTAINS ( "1|10|11", "0" ),
"a in A|B", PATHCONTAINS ( "A|B", "a" )
)
| 10 | 20 | 0 | a in A|B |
|---|---|---|---|
| TRUE | FALSE | FALSE | TRUE |
Everything under Brewing
Brewing itself (key 10) and the three plants below it.
EVALUATE
SELECTCOLUMNS (
FILTER ( Companies, PATHCONTAINS ( PATH ( Companies[Key], Companies[Parent] ), 10 ) ),
"Under Brewing", Companies[Company]
)
ORDER BY [Under Brewing]
| Under Brewing |
|---|
| Bergen plant |
| Brewing |
| Oslo plant |
| Trondheim plant |
How many accounts make up revenue
Revenue (key 10) and the three accounts that add into it.
EVALUATE
ROW (
"Accounts",
COUNTROWS ( FILTER ( Accounts, PATHCONTAINS ( PATH ( Accounts[Key], Accounts[Parent] ), 10 ) ) )
)
| Accounts |
|---|
| 4 |