PATHLENGTH
The number of keys in a PATH text: the row's depth in the hierarchy.
Group: Parent and child. Compatible with DAX.
Syntax
PATHLENGTH ( <path> )
| Parameter | Type | Description |
path | Text | A path as PATH writes it: keys separated by |. |
Returns
Whole number. How many keys the path holds: 1 at the top of the tree, 2 just below it, and so on.
- For a row's path, it is the row's level in the tree.
- Empty text is a path of one empty key, so its length is 1; a blank path has a blank length (example 1).
- Use it to keep the rows of one level, or with
MAXX to know how deep the tree goes, and so how many level columns PATHITEM has to fill.
Examples
The length of a path
EVALUATE
ROW (
"Keys", PATHLENGTH ( "1|20|21" ),
"Empty text", PATHLENGTH ( "" ),
"Blank path is blank", ISBLANK ( PATHLENGTH ( BLANK () ) )
)
| Keys | Empty text | Blank path is blank |
|---|
| 3 | 1 | TRUE |
The level of each company
EVALUATE
SELECTCOLUMNS (
Companies,
"Company", Companies[Company],
"Level", PATHLENGTH ( PATH ( Companies[Key], Companies[Parent] ) )
)
ORDER BY [Level], [Company]
| Company | Level |
|---|
| Example Brewery Group | 1 |
| Brewing | 2 |
| Distribution | 2 |
| Example Brewery Holding | 2 |
| Alnabru depot | 3 |
| Bergen plant | 3 |
| Oslo plant | 3 |
| Trondheim plant | 3 |
How deep the chart of accounts goes
EVALUATE
ROW ( "Levels", MAXX ( Accounts, PATHLENGTH ( PATH ( Accounts[Key], Accounts[Parent] ) ) ) )
PATH, PATHITEM, PATHITEMREVERSE, MAXX.
Last updated · OpenBI Studio 0.3.74