Ax.ext.olap module provides functions calls to interact with Axional OLAP functionalities
1 Ax.ext.olap
Class Ax.ext.olap
Method Summary
Modifier and Type
Method
Description
object
getSchema(string code)
Returns the specified OLAP schema.
object
getCube(string code)
Returns the specified OLAP cube on the target schema
object
buildQuery(object cube, array rows, array cols, config => {})
Returns a OLAP Query object configured with the provided settin
object
Given an OLAP query object, returns it's SQL statement.
object
Given an OLAP query object, returns the statistics stored for that specific query.
resultset
execute(config => {})
This method executes the given OLAP query object and returns the data as a ResultSet.
Method Detail
Ax.ext.olap.getSchema
-
object Ax.ext.olap.getSchema( string code )
- Info:
-
Returns the specified OLAP schema. - Parameters:
- code - OLAP schema code
- Returns:
- object
Example
Copy
<script type='js'> const schema = Ax.ext.olap.getSchema('employees') console.log(schema.getCode()); console.log(schema.getName()); console.log(schema.getRole()); console.log(schema.getRoleName()); schema.getCubeNames().forEach(c => { console.log(c); }); </script>
employees
Employees
null
test_user
Quadrant Analysis
Ax.ext.olap.getCube
-
object Ax.ext.olap.getCube( string code )
- Info:
-
Returns the specified OLAP cube on the target schema - Parameters:
- code - Cube name
- Returns:
- object
Example
Copy
<script type='js'> const schema = Ax.ext.olap.getSchema('employees'); const cube = schema.getCube('Quadrant Analysis'); console.log(cube) </script>
Quadrant Analysis
Ax.ext.olap.buildQuery
-
object Ax.ext.olap.buildQuery( object cube, array rows, array cols, config => { setFilters(array); setTotalGroups(array); setTotalMeasures(array); setTotalFunctions(array); setFilterLevels(array); setFilterMeasures(array); setFilterRules(array); setFilterCount(array); setSorters(array); } )
- Info:
-
Returns a OLAP Query object configured with the provided settin - Parameters:
- cube - The OLAP cube object
- rows - An array of Dimension or Measure specifications for the rows axis
- cols - An array of Dimension or Measure specifications for the columns axis
- filters - An array of Dimension filters
- totalGroups - An array of the total groups
- totalMeasures - An array of total measures filters
- totalFunctions - An array of total functuons filters
- filterLevels - An array of level filters
- filterMeasures - An array of measure filters
- filterRules - An array of rule filters
- filterCount - An array of count filters
- sorters - An array of sorters
- Returns:
- object
Example
Copy
<script type='js'> const schema = Ax.ext.olap.getSchema('employees'); const cube = schema.getCube('Quadrant Analysis'); const rows = ['[Birth Date].[Birth Year]']; const cols = [ '[Employees Gender].[Gender]', '[Measures].[Salary]' ]; const q = Ax.ext.olap.buildQuery(cube, rows, cols, options => { options.setFilters([ '[Birth Date].[1952]', '[Birth Date].[1953]', '[Birth Date].[1954]' ]); }); </script>
Ax.ext.olap.getFinalStatement
-
object Ax.ext.olap.getFinalStatement()
- Info:
-
Given an OLAP query object, returns it's SQL statement. - Returns:
- object
Example
Copy
<script type='js'> const schema = Ax.ext.olap.getSchema('employees'); const cube = schema.getCube('Quadrant Analysis'); const rows = ['[Birth Date].[Birth Year]']; const cols = [ '[Employees Gender].[Gender]', '[Measures].[Salary]' ]; const q = Ax.ext.olap.buildQuery(cube, rows, cols, options => { options.setArgument('filters', [ '[Birth Date].[1952]', '[Birth Date].[1953]', '[Birth Date].[1954]' ]); }); const stmt = q.getFinalStatement(); console.log(stmt) </script>
SELECT YEAR(birth_date) birth_date_1, studio_employees.gender, sum(studio_salaries.salary) salary_m1
FROM studio_salaries, studio_employees
WHERE studio_salaries.emp_no = studio_employees.emp_no
AND (
YEAR(birth_date) IN (1952,1953,1954)
)
GROUP BY birth_date_1, studio_employees.gender
ORDER BY birth_date_1, studio_employees.gender
Ax.ext.olap.getStatistics
-
object Ax.ext.olap.getStatistics()
- Info:
-
Given an OLAP query object, returns the statistics stored for that specific query. - Returns:
- object
Example
Copy
<script type='js'> const schema = Ax.ext.olap.getSchema('employees'); const cube = schema.getCube('Quadrant Analysis'); const rows = ['[Birth Date].[Birth Year]']; const cols = [ '[Employees Gender].[Gender]', '[Measures].[Salary]' ]; const q = Ax.ext.olap.buildQuery(cube, rows, cols, options => { options.setArgument('filters', [ '[Birth Date].[1952]', '[Birth Date].[1953]', '[Birth Date].[1954]' ]); }); const stat = q.getStatistics(); return stat; </script>
Ax.ext.olap.execute
-
resultset Ax.ext.olap.execute( config => { setIwaAccelerate(string); setIwaNoFallback(string); setMaxRows(integer); setRemoveEmpty(integer); setRemoveZeros(integer); setClearGroups(boolean); setTotalByCols(boolean); setLogSql(boolean); } )
- Info:
-
This method executes the given OLAP query object and returns the data as a ResultSet. - Parameters:
- iwaAccelerate - Flag for IWA acceleration (on/off)
- iwaNoFallback - Flag for IWA fallback (on/off)
- maxRows - Max number of rows to return
- removeEmpty - Remove empty rows
- removeZeros - Replace zeros with empty cells
- clearGroups - Flag for clearing value groups
- totalByCols - Flag for clearing value groups
- logSql - Flag to generate SQL logs
- Returns:
- resultset
Example
Copy
<script type='js'> const schema = Ax.ext.olap.getSchema('employees'); const cube = schema.getCube('Quadrant Analysis'); const rows = ['[Birth Date].[Birth Year]']; const cols = [ '[Employees Gender].[Gender]', '[Measures].[Salary]' ]; const q = Ax.ext.olap.buildQuery(cube, rows, cols, options => { options.setArgument('filters', [ '[Birth Date].[1952]', '[Birth Date].[1953]', '[Birth Date].[1954]' ]); }); const res = q.execute(options => { options.setMaxRows(10); options.setClearGroups(10); }); console.log(res); </script>
+------------+-------------+-------------+
|birth_date_1|c1 |c2 |
+------------+-------------+-------------+
| 1952|16.597.297,00|21.476.480,00|
| 1953|18.680.341,00|25.811.366,00|
| 1954|15.787.118,00|23.772.968,00|
+------------+-------------+-------------+