Structure of the basic MDX Query

Source: Internet
Author: User

To specify a dataset, A multidimen1_expressions (MDX) query must contain the following information:

    • The number of axes (up to 128)
    • The members from each dimension to include on each axis
    • The name of the cube that sets the context
    • The members from a slicer dimension on which data is sliced for members from the axis dimensions

This information can be complex. MDX Syntax provides the information in a simple and straightforward manner, using the mdx select statement.

Basic MDX Syntax: select statement

In MDX, the SELECT statement is used to specify a dataset that contains a subset of multidimen1_data. A basic MDX query is structured in the following way:

 
Select [<axis_specification> [, <axis_specification>...] from [<cube_specification>] [where [<slicer_specification>]

The basic mdx select statement contains a select clause and a from clause, with an optional where clause. These syntax elements are shown in the following example:

 
Select {[measures]. [unit sales], [measures]. [store sales]} on columns, {[time]. [2, 1997], [time]. [1998]} on rowsfrom saleswhere ([store]. [USA]. [Ca])

The Select clause determines the axis dimensions of an mdx select statement. two Axis dimensions are defined in this MDX query example. the from clause determines which multidimen1_data source is to be used when extracting data to populate the result set of the mdx select statement.

A Where clause optionally determines which dimension or member to use as a slicer dimension; this restricts the extracting of data to a specific dimension or member. the where clause in this example restricts the data extract for the Axis dimensions to a specific member of the store dimension. an mdx select statement supports other optional syntax elements, such as the With keyword, and the use of MDX functions to construct members by calculation for extension sion in an axis or slicer dimension.

SQL and mdx

The syntax format of the mdx select statement is similar to that of SQL syntax; however, there are several primary differences:

  • Mdx syntax distinguishes sets by surrounding tuples or members with braces (the {And} characters .) mdx queries can have up to 128 axis dimensions in the SELECT statement, but only the first 5 axes have aliases. an axis can be referred to either by its ordinal position within an MDX query, or by its alias if it has been assigned an alias. in the previous example, the columns and rows axis aliases are used. the example query cocould also have been written in the following way, using the ordinal position of each axis:
  • Select {[measures]. [unit sales], [measures]. [store sales]} on axis (0), {[time]. [2, 1997], [time]. [1998]} on axis (1) From saleswhere ([store]. [USA]. [Ca])
  • As with an SQL query, the from clause names the source of the data for the MDX query. however, unlike an SQL query, the from clause in an MDX query is restricted to a single cube. information from other cubes can be retrieved, however, on a value-by-value basis usingLookupcubeFunction.
  • In the MDX query, the where clause describes the slicer dimensions. if a dimension is not mentioned as part of the WHERE clause, Microsoft SQL Server 2000 Analysis Services assumes that any dimension not assigned to an axis dimension is a slicer dimension, and the dimension is filtered on its default members. the where clause can change the filtering process for specified dimensions, allowing fine control of stored ded data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.