Querying – MDX
Let’s build queries!
The cool stuff about PHP Analytics is that you can use a dedicated standard querying language for analytics. When querying an OLAP cube, we use a query language called MDX (Multidimensional Expressions). Let’s see how these queries are composed.
The only mandatory part of an MDX query is the cube that must be requested. For this part, the query only have to specify the cube name.
SELECT FROM Sales
Optionally, you can specify which sets you desire on the axis of the results. You can specify axis names (COLUMNS, ROWS, etc.) or AXIS(n) where n is an integer starting with 0.
SELECT set1 ON ROWS, set2 ON COLUMNS FROM Sales SELECT set1 ON AXIS(0), set2 ON AXIS(1) FROM Sales
If you only want to work with a sub-cube, having fixed some dimensions values, then you have to define the slicer set with the WHERE clause.
SELECT set1 ON ROWS, set2 ON COLUMNS FROM Sales WHERE slicer_set