hierarchy.position
Returns the position of a top-level element in a hierarchy. Elements below the top level return -1. It's the reverse of hierarchy.item.
js
hierarchy.position(dimension, hierarchy, element)Parameters
| Parameter | Type | Description |
|---|---|---|
dimension | string | The dimension's name or id. |
hierarchy | string | The hierarchy's name or id. |
element | string | The element's name. |
Returns
numberThe element's position among the top-level elements, starting at 0, or -1 when it isn't at the top level or can't be found.
Examples
Find a top-level element's position
js
console.log(hierarchy.position("Time", "Default", "FY2026"));
console.log(hierarchy.position("Time", "Default", "Q1"));text
FY2025
Q1
Jan
Feb
Mar
Q2
Apr
May
Jun
FY2026
Q1-26
Jan26
Memotext
1
-1FY2026 is the second top-level element. Q1 sits under FY2025, so it returns -1.