---
url: /process-functions/hierarchy-item.md
description: Returns the top-level element at a position in a hierarchy.
---

# 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](/process-functions/hierarchy-position). To list the elements below one of them, use [hierarchy.descendants](/process-functions/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

The 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

::: code-group

```js [item.js]
let i = 0;
let name;
while ((name = hierarchy.item("Time", "Default", i)) !== "") {
    console.log(i + ": " + name);
    i++;
}
```

```text [Hierarchy]
FY2025
	Q1
		Jan
		Feb
		Mar
	Q2
		Apr
		May
		Jun
FY2026
	Q1-26
		Jan26
Memo
```

```text [Result]
0: FY2025
1: FY2026
2: Memo
```

:::

`Q1`, `Jan` and the other elements below the top level aren't counted, and `hierarchy.item("Time", "Default", 3)` returns `""`.
