hierarchy.item
Returns the top-level element at a position in a hierarchy.
It only counts elements at the top level, not the elements below them. It's the reverse of hierarchy.position. To list the elements below one of them, use hierarchy.descendants.
js
hierarchy.item(dimension, hierarchy, index)Parameters
| Parameter | Type | Description |
|---|---|---|
dimension | string | The dimension's name. |
hierarchy | string | The hierarchy's name. |
index | number | The element's position among the top-level elements, starting at 0. |
Returns
stringThe element's name, or an empty string when the position is out of range or the dimension or hierarchy can't be found.
Examples
List the top-level elements
js
let i = 0;
let name;
while ((name = hierarchy.item("Time", "Default", i)) !== "") {
console.log(i + ": " + name);
i++;
}text
FY2025
Q1
Jan
Feb
Mar
Q2
Apr
May
Jun
FY2026
Q1-26
Jan26
Memotext
0: FY2025
1: FY2026
2: MemoQ1, Jan and the other elements below the top level aren't counted, and hierarchy.item("Time", "Default", 3) returns "".