cube.sliceStatic
Slices data from an intersection of elements from their respective dimensions within the cube, returning static (raw) cell values.
Unlike cube.slice, cube.sliceStatic does not run formulas - it returns the stored cell values as-is.
js
cube.sliceStatic(cubeName, elements...)
cube.sliceStatic(cubeName, elementsArray)
cube.sliceStatic(cubeName, elementsByDimension)Parameters
cubeName(string): The identifier of the cube.elements(string... | string[] | object): One element per dimension in the cube (in dimensional order).
When elements is an object: ^v2.7.194
- Keys must match dimension names.
- Missing dimensions default to "".
Each dimension argument:
- May contain a single value.
- May contain multiple values separated by a pipe (
|). - May be an empty string (
"") to include all elements in that dimension (based on valid intersections).
Returns
slice(object): A slice result set that can be iterated and also read using cursor-style methods.
The returned slice supports:
Size()(number): Total number of rows available in the slice.Reset(): Resets the slice cursor back to the start.EOF()(boolean): Returnstruewhen no more rows are available.Next()(array): Returns the next available row and advances the cursor.GetIndex()(number): Returns the current cursor index (0-based).exportCsv(filename, withHeaders, escapeControlCharacters (optional)): Exports the slice to a CSV file.
As of ^v2.7.194, the returned slice is also iterable, so you can use for...of.
Each row returned from Next() or iteration is an array containing the cell locations elements and value:
[
element1,
element2,
...
elementN,
value
]Examples
Iterable ^v2.7.194
js
// Cube Name - Sales;
// Dimensions: Year, Month, Scenario, Department, Product, Measures
var slice = cube.sliceStatic("Sales", "2017|2018", "", "Actual", "", "", "Units Sold");
for (var row of slice) {
console.log(row);
}Cursor Style
js
// Cube Name - Sales;
// Dimensions: Year, Month, Scenario, Department, Product, Measures
var slice = cube.sliceStatic("Sales", "2017|2018", "", "Actual", "", "", "Units Sold");
while (!slice.EOF()) {
var row = slice.Next();
console.log(row);
}Object Example ^v2.7.194
js
// Cube Name - Sales;
// Dimensions: Year, Month, Scenario, Department, Product, Measures
var slice = cube.sliceStatic("Sales", {
"Year": "2017|2018",
"Scenario": "Actual",
"Measures": "Units Sold"
});
for (var row of slice) {
console.log(row);
}Export to CSV
js
var slice = cube.sliceStatic("Sales", "2017|2018", "", "Actual", "", "", "Units Sold");
slice.exportCsv("exports/sales_slice.csv", true);