Use HIERARCHYLEVEL to find a coordinate's position in a given list. Given a value in a line item, this function uses its coordinate to identify its level in the specified list. This can help you ‌determine how far the item is from the root (top-level ancestor) or from the furthest leaf (bottom-level descendant) in the list.

HIERARCHYLEVEL(List[, Direction[, Level type]])

ArgumentData typeDescription
List (required)List or Time

The name of the list or Time in which the coordinate's distance to either the root ancestor or the most distant leaf descendant is to be returned.

The list you provide must be related to one of the dimensions used by the line item on which the formula is set.

Direction (optional)Keyword

Determines the direction in which the distance is measured.

The keywords are ROOT and LEAF:

  • ROOT - Counts how many ancestors the coordinate has, plus itself.
    This is the default keyword if you omit the Direction argument.
  • LEAF - Counts the number of items in the path to the coordinate's furthest descendant, plus itself.

This argument is optional. But if you want to use the Level type, you must provide this argument.

Level type (optional)Keyword

Determines which list items to include in the count.

The keywords are ALL and EXPLICIT:

  • ALL - Includes all list items in the count.
    This is the default keyword if you omit the Level type argument.
  • EXPLICIT - Includes only one item for each distinct list that makes up the hierarchy.

This argument is optional. But if you want to use this argument, you must provide the Direction argument.

The HIERARCHYLEVEL function returns a numeric value.

This function is only available in the Polaris Calculation Engine.

  HIERARCHYLEVEL(Geographic hierarchy)


For each value of the line item, this function returns the number of ancestors of the coordinate of the value in the Geographic hierarchy hierarchy, including the coordinate itself in the count.

  HIERARCHYLEVEL(Geographic hierarchy, LEAF, ALL)


This function returns the distance to the furthest leaf descendant of the coordinate within the given list Geographic hierarchy, plus itself, including ALL the list items in the count.

The function's result depends on the type of list and the coordinate's position within it:

  • If the coordinate isn't part of the specified list, the result is 0.
  • Returns 0 if,
    • In the ROOT direction, the coordinate doesn't have a root ancestor.
    • In the LEAF direction, the coordinate doesn't have any leaf descendants.
  • Top-level items are treated as the (unique) root of the corresponding lists.
  • The list you provide must be related to one of the dimensions used by the line item on which the formula is set.
  • It also won’t work with ancestor hierarchies of the target dimension.
    For example, if your line item uses listB as its dimension, you can’t use this function with listA, if listA is a parent of listB.

The following is an example of a Geographic hierarchy:



Spain



Italy




England



Scotland



Wales



Greater London


United Kingdom



France



Germany


Europe




India



China



Japan


Asia






San Jose




San Francisco




Los Angeles



California



Texas



New York


United States



Canada


North America


All regions



All regions has three children: North America, Asia, and Europe.

  • North America has two children: Canada and United States.
    • United States has three children: New York, Texas, and California.
      • California has three children: Los Angeles, San Francisco, and San Jose.
  • Asia has three children: Japan, China, and India.
  • Europe has five children: Germany, France, United Kingdom, Italy, and Spain.
    • United Kingdom has four children: Greater London, Wales, Scotland, and England.

The following module has three line items: 

  • Item contains all the list items from Geographic hierarchy.
  • Result 1 , Result 2,  Result 3, and Result 4 have the HIERARCHYLEVEL formulas.
Item

Result 1

  HIERARCHYLEVEL(Geographic hierarchy)

Result 2

  HIERARCHYLEVEL(Geographic hierarchy, LEAF)

Result 3

  HIERARCHYLEVEL(Geographic hierarchy, ROOT, EXPLICIT)

Result 4

  HIERARCHYLEVEL(Geographic hierarchy, ROOT, ALL)

Spain3123
Italy3123
England4124
Scotland4124
Wales4124
Greater London4124
United Kingdom3223
France3123
Germany3123
Europe2322
India3123
China3123
Japan3123
Asia2222
San Jose5125
San Francisco5125
Los Angeles5125
California4224
Texas4124
New York4124
United States3323
Canada3123
North America2422
All regions1511