PATHITEMREVERSE
The key at a position in a PATH text, counted from the current row up.
Group: Parent and child. Compatible with DAX.
Syntax
PATHITEMREVERSE ( <path>, <position> [, <type>] )
| Parameter | Type | Description |
|---|---|---|
path | Text | A path as PATH writes it: keys separated by |. |
position | Whole number | Which key, counted from the end: 1 is the row itself, 2 its parent. |
type | Keyword optional | TEXT (or 0) to get the key as text, which is what you get when it is left out; INTEGER (or 1) to get a whole number. Any other value is an error. |
Returns
Text or whole number. The key at that position from the end, or BLANK when the path has no key there.
Remarks
- Position 1 is the last key of the path, the row's own; 2 is its parent, 3 the parent's parent. The path's length is the top.
- A position before the top of the path, 0 or a negative one gives BLANK.
- It gives what
PATHITEM ( path, PATHLENGTH ( path ) + 1 - position )gives.
Examples
The keys of a path, from the end
EVALUATE
ROW (
"Itself", PATHITEMREVERSE ( "1|20|21", 1 ),
"Parent", PATHITEMREVERSE ( "1|20|21", 2, INTEGER ),
"Its parent", PATHITEMREVERSE ( "1|20|21", 3 ),
"Beyond the top", PATHITEMREVERSE ( "1|20|21", 4 )
)
| Itself | Parent | Its parent | Beyond the top |
|---|---|---|---|
| 21 | 20 | 1 | (blank) |
Each company's parent, by name
EVALUATE
SELECTCOLUMNS (
Companies,
"Company", Companies[Company],
"Parent", LOOKUPVALUE (
Companies[Company],
Companies[Key], PATHITEMREVERSE ( PATH ( Companies[Key], Companies[Parent] ), 2, INTEGER )
)
)
ORDER BY [Company]
| Company | Parent |
|---|---|
| Alnabru depot | Distribution |
| Bergen plant | Brewing |
| Brewing | Example Brewery Group |
| Distribution | Example Brewery Group |
| Example Brewery Group | (blank) |
| Example Brewery Holding | Example Brewery Group |
| Oslo plant | Brewing |
| Trondheim plant | Brewing |