官术网_书友最值得收藏!

Time for action – writing an MDX query

In this example, you will learn more about the MDX structure and how to write queries in the MDX language.

  1. Open SQL Server Management Studio, connect to the Analysis Services instance, and click on Chapter 02 SSAS Multi Dimensional, and then click on New Query.
  2. In the New Query window, write the following expression:
    select [Order Date].[Calendar Year].members on 0
    from [Internet Sales]

    You will see a list of the years, the sales amount for each year, and the grand total.

  3. Now, run the following statement:
    select [Sales Territory].[Sales Territory Country].members on 0,
    [Order Date].[Calendar].[Calendar Year].members on 1
    from [Internet Sales]
  4. Check the result and you will see the years listed in each row, the countries listed in each column, and the Sales Amount measure shown in each cell, which represents the sales amount of that country in that year.
    Time for action – writing an MDX query

What just happened?

MDX is a query language that returns the results in a multidimensional format. In this example, you saw how we define an axis in the output result set. In the first query (step 2), there is only one axis used, which is the column axis. In the second query (step 5), two axes are used, the column axis shows the countries and the row axis shows the years.

An MDX query is not limited to only two axes; you can write an MDX query with 128 axes , for example. However, the client tools are limited to show more than two axes for example, in SSMS, you cannot write a query with more than two axes because it cannot be shown as a result.

The MDX select query structure consists of the SELECT clause on multiple axes, FROM clause, and the WHERE clause.

SELECT [<axis_specification>
       [, <axis_specification>...]]
  FROM [<cube_specification>]
[WHERE [<slicer_specification>]]

There are many MDX functions to work with time, hierarchies, and other common applications that are helpful when writing MDX queries. You will work with a few of them in the following examples.

主站蜘蛛池模板: 三台县| 虹口区| 汉寿县| 竹北市| 礼泉县| 昌图县| 连城县| 高邮市| 金门县| 抚州市| 阳高县| 阳山县| 石景山区| 阿合奇县| 福贡县| 新丰县| 呈贡县| 固始县| 绥化市| 江口县| 泗水县| 安顺市| 宁蒗| 祁阳县| 尼玛县| 扬中市| 武冈市| 正定县| 岢岚县| 牙克石市| 淮阳县| 万年县| 曲靖市| 青河县| 辽宁省| 金寨县| 海伦市| 呼伦贝尔市| 郴州市| 远安县| 彭山县|