Skip to content

hierarchy.structure ​

Nests one parent element under another, creating either if they don't exist.

Use it to build the parent levels of a hierarchy, and hierarchy.group for the leaf elements under them.

js
hierarchy.structure(dimension, hierarchy, parent, child, weight)

Parameters ​

ParameterTypeDescription
dimensionstringThe dimension's name or id.
hierarchystringThe hierarchy's name or id.
parentstringThe parent element's name.
childstringThe child element's name.
weightnumberOptional. 1 to add the child into the parent, or -1 to subtract it. Defaults to 1.

Returns ​

string

An empty string when it succeeds, or an error message when it fails, such as when the link would be circular.

Examples ​

Add an element under a parent ​

js
hierarchy.structure("Account", "Profit and Loss", "EBITDA", "Total Revenue");

Build a hierarchy ​

Use structure for the parent levels and group for the leaf elements under them.

js
// Parent levels
hierarchy.structure("Account", "Profit and Loss", "Net Profit", "Total Revenue");
hierarchy.structure("Account", "Profit and Loss", "Net Profit", "Total Expenses", -1); // Subtract expenses

// Leaf elements
hierarchy.group("Account", "Profit and Loss", "Total Revenue", "600010");
hierarchy.group("Account", "Profit and Loss", "Total Revenue", "600020");
hierarchy.group("Account", "Profit and Loss", "Total Expenses", "700010");
text
Net Profit
├── Total Revenue
│   ├── 600010
│   └── 600020
└── Total Expenses (−1)
    └── 700010