---
url: /process-functions/hierarchy-elementhasancestor.md
description: >-
  Checks whether an element has another element anywhere above it in a
  hierarchy, not just as its immediate parent.
---

# hierarchy.elementHasAncestor

Checks whether an element has another element anywhere above it in a hierarchy, not just as its immediate parent.

```js
hierarchy.elementHasAncestor(dimension, hierarchy, element, ancestorName)
```

## Parameters

| Parameter | Type | Description |
|---|---|---|
| `dimension` | `string` | The dimension's name or id. |
| `hierarchy` | `string` | The hierarchy's name or id. |
| `element` | `string` | The element to check. |
| `ancestorName` | `string` | The ancestor to look for. It can be prefixed with the hierarchy. |

## Returns

`true` when the ancestor is found above the element, otherwise `false`.

## Examples

```js
const value = hierarchy.elementHasAncestor("Time", "Default (Calendar)", "August", "2015");
```
