MDX Query Format

This overview presentation of a high-level MDX query structure gives you a summary of the required and optional elements you can use to write MDX queries for Essbase multidimensional analysis.

Every query using the SELECT statement has the following basic format. Items in [brackets] are optional.

[<with_section>]
[<insert_clause>]
[<export_clause>]
SELECT [<axis_specification>
       [, <axis_specification>...]]
  <subselect> | FROM <cube_specification> 
[WHERE [<slicer_specification>]]

Table 4-1 Description of MDX Query Elements

Item Description
<with_section> An optional section, beginning with the keyword WITH, in which you can define referenceable sets or members.
<insert_clause> An optional clause for inserting tuples of data from a source to a target.
<export_clause> An optional clause to save query results to a file on Essbase. This is an alternative to viewing the query output on a client.
SELECT A literal keyword that must precede axis specifications.
[<axis_specification> [,<axis_specification>...]] Any number of comma-separated axis specifications. Axes represent an n dimensional cube schema. Each axis is conceptually a framework for retrieving a data set; for example, one axis could be thought of as a column, and the next could be considered a row. See MDX Axis Specifications for more information.
[<subselect>] An optional sub selection to filter an axis specification. See MDX Sub Select.
FROM A literal keyword that must precede the cube specification.
<cube_specification> The name of the database from which to select.
WHERE A literal keyword that must precede the slicer specification, if one is used.
<slicer specification> A tuple, member, or set representing any further level of filtering you want done on the results. For example, you may want the entire query to apply only to Actual Sales in the Sample Basic database, excluding budgeted sales. The WHERE clause might look like the following:WHERE ([Scenario].[Actual], [Measures].[Sales])