Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum Rss Feed

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Rss Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Dec 16, 2002

MDX Essentials: Structure of the MDX Data Model - Page 4

By William Pearson

Practical Examples

Because we have covered enough of the basics to begin practicing some of the concepts, let's build a simple query and reinforce our understanding. We will return to the MDX Sample Application (installed with Analysis Services, and discussed further in Article One, MDX at First Glance: Introduction to MDX Essentials), and take the following steps, to practice interacting with Analysis Services in a hands-on manner.

  1. Go to the Start button on the PC, and then navigate to Microsoft SQL Server -> Analysis Services.
  2. Click MDX Sample Application.

We are initially greeted by the Connect dialog, shown in Illustration 1 below.

Illustration 1: The Connect Dialog for the MDX Sample Application

The illustration above depicts the name of one of my servers, RAPHAEL, and properly indicates that we will be connecting via the MSOLAP provider (the default).

  1. Click OK.

The MDX Sample Application window appears.

  1. Clear the top area (the Query pane) of any queries or remnants that might appear.
  2. Ensure that FoodMart 2000 is selected as the database name in the DB box of the toolbar.
  3. Select the HR cube in the Cube drop-down list box.

The MDX Sample Application window should resemble that shown below, complete with the information from the HR cube displaying in the Metadata tree (in the left section of the Metadata pane, between the Query pane at the top of the application window and the Results pane, at the bottom.).

Illustration 2: The MDX Sample Application Window (Compressed)

We will begin with an illustration: We are asked by an information consumer in Human Relations to provide the total headcount for the years 1997 and 1998 individually for the entire organization.

  1. Type the following query into the Query pane:
-- MDX02-1: Tutorial Query No. 1 SELECT {([Time].[1997]), ([Time].[1998])}ON COLUMNS FROM HR WHERE ([Measures].[Count])

The diagram below labels the various parts of the query:

Illustration 3: Labeled Parts of a Basic MDX Query

  1. Click Query on the top menu, and then select Run.

We see the results below, which appear in the Query pane as soon as Analysis Services fills the cells that it determines to be specified by the query.

Illustration 4: The Initial Query Results

Note: For an explanation of the comment line, together with other general discussion regarding attributes of the basic MDX query structure, see the first article of the series.

The query delivers the results that were requested by the information consumer. The results display columns, but no rows, because we specified only one axis. We will add specification of the Row axis in the next example.

Anytime we use single tuples, such as we do in specifying the "x" axis above (our only axis), we enclose the tuples in curled braces to signify that they are tuples contained within a set, as shown.

  1. Save the query by selecting File -> Save As, and call the file MDX02-1.

Page 5: Practical Example (Continued)

MS SQL Archives

Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM