![]() Previous |
![]() Next |
HIER_DEPTH returns a number representing the level depth of either all members of a hierarchy or a particular member, where 0 is the top level. The hierarchy can be either level-based or value-based.
Syntax
HIER_DEPTH ( [member_expression] [WITHIN] {DIMENSION dimension_id | HIERARCHY hierarchy_id} )
Arguments
member_expression
Identifies a single dimension member within the hierarchy used for the calculation. If this optional argument is specified, then the result does not vary across dimension members.
dimension_id
The dimension over which the values are calculated using the default hierarchy.
hierarchy_id
The hierarchy over which the values are calculated. If dimension_id is used instead, the default hierarchy is used.
Example
This example returns the depth of each member in the default hierarchy of the Time dimension.
HIER_DEPTH(DIMENSION "TIME")
| Time | Depth |
|---|---|
| 2006 | 1 |
| Q1.06 | 2 |
| Q2.06 | 2 |
| Q3.06 | 2 |
| Q4.06 | 2 |
| JAN-06 | 3 |
| FEB-06 | 3 |
| MAR-06 | 3 |
| APR-06 | 3 |
| MAY-06 | 3 |
| JUN-06 | 3 |
| JUL-06 | 3 |
| AUG-06 | 3 |
| SEP-06 | 3 |
| OCT-06 | 3 |
| NOV-06 | 3 |
| DEC-06 | 3 |
The next example returns 2 as the depth of Italy in the default Customer hierarchy.
HIER_DEPTH('ITA' WITHIN DIMENSION CUSTOMER)