Skip to content

hierarchy.unwind ​

Removes an element, and everything below it, from a hierarchy.

What it does:

  • Removes the element from every parent it has in the hierarchy, or from the top level.
  • Removes everything below it too. Anything that's also under a parent outside this branch stays there.
  • Deletes any parents it removes.
  • Keeps leaf elements in the dimension. If a leaf isn't in another hierarchy, it becomes an orphan.

To take a leaf element out from under one parent, use hierarchy.removeChild instead. To remove a leaf element from the dimension altogether, including from every hierarchy, use element.delete.

WARNING

hierarchy.unwind is for parents and elements at the top level. For a leaf element under a parent it usually returns "Error: Element not found.", depending on how the leaf was added, so use hierarchy.removeChild for those.

js
hierarchy.unwind(dimension, hierarchy, element)

Parameters ​

ParameterTypeDescription
dimensionstringThe dimension's name or id.
hierarchystringThe hierarchy's name or id.
elementstringThe element to remove, along with everything below it.

Returns ​

string

An empty string when it succeeds, or an error message when the dimension, hierarchy or element can't be found.

Examples ​

js
hierarchy.unwind("Account", "Profit and Loss", "EBITDA");
text
Net Profit
	EBITDA
		Revenue
			600010
			600020
		Operating Expenses
			700010
	Depreciation
		800010
KPIs
	Revenue
		600010
		600020
text
Net Profit
	Depreciation
		800010
KPIs
	Revenue
		600010
		600020

EBITDA and Operating Expenses are removed and deleted. Revenue stays under KPIs, because it also sits there. 700010 is no longer in the hierarchy, so if it isn't in another hierarchy it becomes an orphan.