OpenBI Docs Buy

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> )
ParameterTypeDescription
pathTextA 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.

Remarks

  • 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 () ) )
)
KeysEmpty textBlank path is blank
31TRUE

The level of each company

EVALUATE
SELECTCOLUMNS (
    Companies,
    "Company", Companies[Company],
    "Level", PATHLENGTH ( PATH ( Companies[Key], Companies[Parent] ) )
)
ORDER BY [Level], [Company]
CompanyLevel
Example Brewery Group1
Brewing2
Distribution2
Example Brewery Holding2
Alnabru depot3
Bergen plant3
Oslo plant3
Trondheim plant3

How deep the chart of accounts goes

EVALUATE
ROW ( "Levels", MAXX ( Accounts, PATHLENGTH ( PATH ( Accounts[Key], Accounts[Parent] ) ) ) )
Levels
5

PATH, PATHITEM, PATHITEMREVERSE, MAXX.

Last updated · OpenBI Studio 0.3.74