PARENT
Returns the name of a parent element for a specified element in a dimension.
Syntax
PARENT(Dimension, Element, Index)
Parameters
This table describes the parameters of the PARENT function:
| Parameter | Type | Description |
|---|---|---|
| Dimension | String | The name of the dimension that contains the element. |
| Element | String | The name of the element whose parent to retrieve. The value can be an element name or an element reference returned by another function, such as DE.FIRST, DE.NEXT, or ELEMENTINHIERARCHY. |
| Index | Numeric | The 1-based index of the parent to retrieve. An element can have multiple parents in a many-to-many hierarchy. Specify 1 for the first parent, 2 for the second parent, and so on. |
Return values
The PARENT function returns a string that contains the name of the parent element.
The function returns an empty string in these cases:
- The
Indexvalue is less than 1. - The element has fewer parents than specified by
Index. - The dimension doesn't exist.
- The specified element doesn't exist in the dimension.
Usage notes
- This function is available under the
DE.PARENTNAMEalias. Both names are interchangeable and behave identically. - In a simple hierarchy, where each element has a single parent, use
Index = 1. - In many-to-many hierarchies, an element can have multiple parents. The
Indexparameter determines which parent is returned based on the internal storage order of the parent relationships. - Use
DE.PARENTSCOUNT(Dimension, Element)to determine the number of parent elements before iterating. - The result preserves the hierarchy context of the specified element. You can use the returned value directly as an element parameter in other functions, such as
DB,PARENT(to get grandparents), orDE.LEVEL. - If the specified dimension cannot be found or loaded, the function returns an empty string without raising an error.
Examples
Example 1
PARENT("Time", "Jan 2024", 1)
Returns the parent of Jan 2024 in the Time dimension, for example, Q1 2024.
Example 2
PARENT("Organization", "Sales Team A", 2)
Returns the second parent of Sales Team A. This is useful in many-to-many hierarchies where an element belongs to multiple consolidated elements.
Example 3
DB("Revenue", PARENT("Time", "Jan 2024", 1), "Actual")
Retrieves a value from the Revenue cube by using the parent of the current time element.