Ax.ext.olap module provides functions calls to interact with Axional OLAP functionalities

 

1 Ax.ext.olap.getSchema

Returns the specified OLAP schema.

1. Ax.ext.olap.getSchema

object Ax.ext.olap.getSchema ( string code )
Parameters
NameTypeRequiredDescription
codestringOLAP schema code
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
 

1.1 getCube

Returns the specified OLAP cube on the target schema.

1. getCube

object getCube ( string code )
Parameters
NameTypeRequiredDescription
codestringCube name
Example
Copy
<script type='js'>
    const schema = Ax.ext.olap.getSchema('employees');
    const cube = schema.getCube('Quadrant Analysis');
    console.log(cube)
</script>
Quadrant Analysis
 

2 Ax.ext.olap.buildQuery

Returns a OLAP Query object configured with the provided settings.

1. Ax.ext.olap.buildQuery

object Ax.ext.olap.buildQuery( option => {
    option.setArgument('cube', value);
    option.setArgument('cols', value);
    option.setArgument('rows', value);
    option.setArgument('filters', value);
});
Parameters
NameTypeRequiredDescription
cubestringThe OLAP cube object
colsstringAn array of Dimension or Measure specifications for the columns axis
rowsstringAn array of Dimension or Measure specifications for the rows axis
filtersstringAn array of Dimension filters
Example
Copy
<script type='js'>
	const schema = Ax.ext.olap.getSchema('employees');
	const cube = schema.getCube('Quadrant Analysis');
	const q = Ax.ext.olap.buildQuery(options => {
		options.setArgument('cube', cube);
		options.setArgument('cols', [
			'[Employees Gender].[Gender]',
			'[Measures].[Salary]'
		]);
		options.setArgument('rows', [
			'[Birth Date].[Birth Year]'
		]);
		options.setArgument('filters', [
			'[Birth Date].[1952]',
			'[Birth Date].[1953]',
			'[Birth Date].[1954]'
		]);
	});
</script>
 

2.1 getFinalStatement

Given an OLAP query object, returns it's SQL statement.

1. getFinalStatement

object getFinalStatement ( )
Example
Copy
<script type='js'>
	const schema = Ax.ext.olap.getSchema('employees');
	const cube = schema.getCube('Quadrant Analysis');
	const q = Ax.ext.olap.buildQuery(options => {
		options.setArgument('cube', cube);
		options.setArgument('cols', [
			'[Employees Gender].[Gender]',
			'[Measures].[Salary]'
		]);
		options.setArgument('rows', [
			'[Birth Date].[Birth Year]'
		]);
		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
 

2.2 getStatistics

Given an OLAP query object, returns the statistics stored for that specific query.

1. getStatistics

object getStatistics ( )
Example
Copy
<script type='js'>
    const schema = Ax.ext.olap.getSchema('employees');
    const cube = schema.getCube('Quadrant Analysis');
	const q = Ax.ext.olap.buildQuery(options => {
		options.setArgument('cube', cube);
		options.setArgument('cols', [
			'[Employees Gender].[Gender]',
			'[Measures].[Salary]'
		]);
		options.setArgument('rows', [
			'[Birth Date].[Birth Year]'
		]);
		options.setArgument('filters', [
			'[Birth Date].[1952]',
			'[Birth Date].[1953]',
			'[Birth Date].[1954]'
		]);
	});
    const stat = q.getStatistics();
    return stat;
</script>
 

2.3 execute

This method executes the given OLAP query object and returns the data as a ResultSet.

1. execute

object execute( option => {
    option.setArgument('iwa-accelerate', value);
    option.setArgument('iwa-fallback', value);
    option.setArgument('max-rows', value);
    option.setArgument('clear-groups', value);
    option.setArgument('log-sql', value);
    option.setArgument('log-info', value);
});
Parameters
NameTypeRequiredDescription
iwa-acceleratestringFlag for IWA acceleration (on/off)
iwa-fallbackstringFlag for IWA fallback (on/off)
max-rowsintegerMax number of rows to return
clear-groupsbooleanFlag for clearing value groups
log-sqlbooleanFlag to generate SQL logs
log-infobooleanFlag to generate INFO logs
Example
Copy
<script type='js'>
    const schema = Ax.ext.olap.getSchema('employees');
    const cube = schema.getCube('Quadrant Analysis');
	const q = Ax.ext.olap.buildQuery(options => {
		options.setArgument('cube', cube);
		options.setArgument('cols', [
			'[Employees Gender].[Gender]',
			'[Measures].[Salary]'
		]);
		options.setArgument('rows', [
			'[Birth Date].[Birth Year]'
		]);
		options.setArgument('filters', [
			'[Birth Date].[1952]',
			'[Birth Date].[1953]',
			'[Birth Date].[1954]'
		]);
	});
    const res = q.execute(options => {
		options.setArgument('max-rows', '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|
+------------+-------------+-------------+