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"] }. Addhierarchyto 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-nextandremoveapply to thesetthat follows them.
Instructions
| Code | Instruction | Argument |
|---|---|---|
expand | Expand | |
expand-all | Expand All | |
expand-above | Reverse Subtotals | Put it before the expand. |
expand-next | Expand Next Instruction | |
collapse-next | Collapse Next Instruction | |
remove | Remove Using The Next Instruction | |
remove-all-consolidations | Remove Consolidations | |
remove-n-level | Remove Leaf Elements | |
remove-duplicates | Remove Duplicates | |
sort-by-name | Sort By Name Ascending | |
sort-by-name-desc | Sort By Name Descending | |
insert-next | Insert The Next Element | Hierarchy name |
insert-previous | Insert The Previous Element | Hierarchy name |
insert-variable | Insert A Variable Value | Variable name |
use-alias | Set The Alias | Alias name |
indent | Indent | |
reset-indents | Reset 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 }
]