Skip to content

hierarchy.position ​

Returns the position of a top-level element in a hierarchy. Elements below the top level return -1. It's the reverse of hierarchy.item.

js
hierarchy.position(dimension, hierarchy, element)

Parameters ​

ParameterTypeDescription
dimensionstringThe dimension's name or id.
hierarchystringThe hierarchy's name or id.
elementstringThe element's name.

Returns ​

number

The element's position among the top-level elements, starting at 0, or -1 when it isn't at the top level or can't be found.

Examples ​

Find a top-level element's position ​

js
console.log(hierarchy.position("Time", "Default", "FY2026"));
console.log(hierarchy.position("Time", "Default", "Q1"));
text
FY2025
	Q1
		Jan
		Feb
		Mar
	Q2
		Apr
		May
		Jun
FY2026
	Q1-26
		Jan26
Memo
text
1
-1

FY2026 is the second top-level element. Q1 sits under FY2025, so it returns -1.