OpenBI Docs Buy

PATH

The keys from the top of a parent-child hierarchy down to the current row, joined with |.

Group: Parent and child. Compatible with DAX.

Syntax

PATH ( <ID_columnName>, <parent_columnName> )
ParameterTypeDescription
ID_columnNameColumnThe column of keys: each row's own key.
parent_columnNameColumnThe column with the key of each row's parent; blank for a row at the top.

Returns

Text. The keys from the top of the tree down to the current row, separated by |.

Remarks

  • Both arguments are columns of one table of the model: its key column and its parent column. A column of a table made in the query, with DATATABLE or in a variable, is an error.
  • It works on one row of that table at a time: in a calculated column, or in an iterator over the table such as ADDCOLUMNS or FILTER. Anywhere else it is an error.
  • A row whose parent is blank is at the top, and its path is just its own key.
  • Parents are looked up in the whole table, whatever filters are on it: in a table filtered to one company, that company's path still runs up to the top (example 3).
  • It is usually written once, as a calculated column, and read with PATHLENGTH, PATHITEM, PATHITEMREVERSE and PATHCONTAINS.
  • Keys are matched without regard to case, as OAX compares text: a parent written a finds the row whose key is A.
  • A parent that is no row's key is taken as the top: the path begins with it, as written, so a row d whose parent x is no key has the path x|d.

Compared with DAX

Power BI refuses a parent that is no row's key: the query fails, and a model with such a calculated column does not load. OpenBI answers, beginning the path with that parent, and when a calculated column's PATH meets one as the model loads, it warns, naming the column and its first such rows. On OpenBI Server the warning is in the refresh's history. Fix the data to have the same answer in both.

Examples

The path of each company

EVALUATE
ADDCOLUMNS ( Companies, "Path", PATH ( Companies[Key], Companies[Parent] ) )
ORDER BY Companies[Key]
Companies[Key]Companies[Parent]Companies[Company]Path
1(blank)Example Brewery Group1
101Brewing1|10
1110Bergen plant1|10|11
1210Oslo plant1|10|12
1310Trondheim plant1|10|13
201Distribution1|20
2120Alnabru depot1|20|21
301Example Brewery Holding1|30

The financial accounts and their way up

Only the accounts of one section are listed; their paths still begin at the top of the chart of accounts.

EVALUATE
SELECTCOLUMNS (
    FILTER ( Accounts, Accounts[Section] = "Financial" ),
    "Account", Accounts[Account],
    "Path", PATH ( Accounts[Key], Accounts[Parent] )
)
ORDER BY [Path]
AccountPath
Net financial items1|2|80
Interest income1|2|80|8050
Currency gains and losses1|2|80|8060
Interest expense1|2|80|8150

Filters do not cut the path

EVALUATE
CALCULATETABLE (
    ADDCOLUMNS ( Companies, "Path", PATH ( Companies[Key], Companies[Parent] ) ),
    Companies[Key] = 21
)
Companies[Key]Companies[Parent]Companies[Company]Path
2120Alnabru depot1|20|21

PATHLENGTH, PATHITEM, PATHITEMREVERSE, PATHCONTAINS, LOOKUPVALUE.

Last updated · OpenBI Studio 0.3.74