Skip to content

cube.slice

Slices data from an intersection of elements from their respective dimensions within the cube.

js
cube.slice(name, e1 - eN)
cube.slice(name, e1 - eN)

Parameters

  • Name - The identifier of the cube.
  • e1 - eN - An element for each dimension within the cube which when used, finds a specific intersection.

Methods

  • EOF - Returns a boolean value which indicates if the last row has been read.
  • Next - Returns the next available row.

Example

js
// Cube Name - Sales.  
// Dimensions: year, month, scenario, department, product, measures 
let slice = cube.slice("Sales", "2017|2018", "", "Actual", "", "", "Units sold");
while( !slice.EOF() ) { 
    let elms = slice.Next(); 
} 
// The following rows will be stored in the variable elms for every iteration, until it reaches the last record. 
// ["2017", "Jan", "Actual", "Store 01", "Product A", "Units Sold", 19200] 
// ["2017", "Feb", "Actual", "Store 01", Product A", "Units Sold", 374] 
// ... 
// ["2018", "Dec", "Actual", "Store 10", "Product Z", "Units Sold", 152]
// Cube Name - Sales.  
// Dimensions: year, month, scenario, department, product, measures 
let slice = cube.slice("Sales", "2017|2018", "", "Actual", "", "", "Units sold");
while( !slice.EOF() ) { 
    let elms = slice.Next(); 
} 
// The following rows will be stored in the variable elms for every iteration, until it reaches the last record. 
// ["2017", "Jan", "Actual", "Store 01", "Product A", "Units Sold", 19200] 
// ["2017", "Feb", "Actual", "Store 01", Product A", "Units Sold", 374] 
// ... 
// ["2018", "Dec", "Actual", "Store 10", "Product Z", "Units Sold", 152]

TIP

  • Each argument for the dimensions can have a single value or multiple values (separated by a pipe "|")
  • An argument which is empty will include all elements within the particular dimension depending on the intersection of cells