MDX at First Glance: Introduction to SQL Server MDX Essentials - Page 5

November 6, 2002

Let's create another query to conclude this introductory session. This time, let's say that information consumers have asked for a comparison between the total US warehouse sales for the first and second quarters of 1997. We will again create a query against our Warehouse cube to generate this information.

  1. Click the New Query button (depicted in the illustration below).

Illustration 6: The New Query Button

We might also have selected File -> New from the top menu.

  1. Type the following query into the Query pane:
    --MDX01-2:  Basic Query 2
    {[Time].[1997].[Q1],[Time].[1997].[Q2]}ON COLUMNS,
    {[Warehouse].[All Warehouses].[USA]}  ON ROWS
    FROM Warehouse
    WHERE  ([Measures].[Warehouse Sales])
Because we have specified the Warehouse Sales measure in the WHERE statement, we have made it the slicer dimension. The slicer shows that we have picked only the Warehouse Sales measure from the measures dimension. We will work with slicer dimensions, as well as with the other components of the simple queries we have examined in this lesson (and far more), as we progress through the MDX Essentials series.

  1. Click Query on the top menu, then select Run, as shown below:

Illustration 7: Select Run from the Query Menu

Alternatively, F5 or the Run Query button might be selected for the same effect.

We see the results below, which appear as soon as Analysis Services fills the cells specified by the query.

Illustration 8: The Query Results

  1. Save the query as MDX01-2.
  2. Exit the Sample Application.
Our intent with the above examples is to begin our exploration of MDX and to provide a first exposure to simple query structure. We will cover the details of the syntax and its arrangement, and a host of other considerations, as we progress through the series.

Page 6: Next in Our Series...