Skip to content

Set Instructions in Scripts ​

cube.crosstab and dimension.set take set instructions as an array, run in order, the same as a Workview set.

js
dimension.set("Region", [{ set: ["All Regions"] }, "expand-all", "use-alias:Description"]);

Writing instructions ​

  • Selecting elements: { set: ["All Regions", "North"] }. Add hierarchy to take them from a named hierarchy: { set: ["2026"], hierarchy: "Fiscal" }. To choose a hierarchy for each element separately, use { name, hierarchy } objects: { set: [{ name: "2026", hierarchy: "Fiscal" }] }.
  • Actions: plain strings, such as "expand-all".
  • Actions with an argument: the code, a colon, then the argument, such as "use-alias:Description".
  • Next-instruction actions: expand-next, collapse-next and remove apply to the set that follows them.

Instructions ​

CodeInstructionArgument
expandExpand
expand-allExpand All
expand-aboveReverse SubtotalsPut it before the expand.
expand-nextExpand Next Instruction
collapse-nextCollapse Next Instruction
removeRemove Using The Next Instruction
remove-all-consolidationsRemove Consolidations
remove-n-levelRemove Leaf Elements
remove-duplicatesRemove Duplicates
sort-by-nameSort By Name Ascending
sort-by-name-descSort By Name Descending
insert-nextInsert The Next ElementHierarchy name
insert-previousInsert The Previous ElementHierarchy name
insert-variableInsert A Variable ValueVariable name
use-aliasSet The AliasAlias name
indentIndent
reset-indentsReset Indents

Workview-only instructions

Other set instructions are accepted but do nothing in a script. These include formatting, styles, suppression, sorting or grouping by value, blank spaces, formulas and variances. To leave out empty rows in a crosstab, use its suppress option.

Examples ​

js
// All regions except South
const regions = dimension.set("Region", [
    { set: ["All Regions"] },
    "expand",
    "remove",
    { set: ["South"] }
]);
js
[
    { name: "All Regions", label: "All Regions", hierarchy: "Default", level: 0, consolidation: true },
    { name: "North", label: "North", hierarchy: "Default", level: 1, consolidation: false }
]