---
url: /process-functions/hierarchy-parentbyindex.md
description: Returns the name of one of an element's immediate parents.
---

# hierarchy.parentByIndex

Returns the name of one of an element's immediate parents.

```js
hierarchy.parentByIndex(dimension, hierarchy, element, index)
```

## 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. |
| `index` | `number` | The parent's position, starting at `0`. |

## Returns

The parent's name, or a message starting with `"Error:"` when there's no parent at that position or something can't be found.

## Examples

```js
const parent = hierarchy.parentByIndex("Account", "Management Profit and Loss", "EBIT", 0);
```

`parent` is the name of the first parent of `EBIT` in the Management Profit and Loss hierarchy.
