Site sponsored by: Idera Try Idera’s new SQL admin toolset
SQL Server Performance

  • Home
  • Articles
  • Forums
  • Tips
  • Quiz
  • FAQ's
  • Blogs
  • Software
  • Books
  • About Us
RSS Feeds
Sign in | Join


Article Topics

All Articles
Performance Tuning
Audit
Business Intelligence
Clustering
Reporting Services
Developer
General DBA
ASP.NET / ADO.NET

Write for Us

Share you SQL Server knowledge with others and raise your profile in the community More...
Latest Articles

Policy Based Management in SQL Server 2008
Inside SQL Server Cluster Setup and Troubleshooting Techniques - Part I ...
Configure and Manage Policy Based Management in SQL Server 2008 ...
Using Column Sets with Sparse Columns

More     
 
Latest FAQ's

Cannot Start SQL Server Service
Users are able to connect to report manager but not able ...
Errors when SQL Server Snapshot Replication is Running
How to Display Server Name or IP Address in a Reporting ...

More     
   
Latest Software Reviews

Spotlight on ApexSQL Doc 2008
ApexSQL Enforce
Embarcadero Change Manager
SQL Server DBA Dashboard

More     

articles >> business intelligence >> Optimizing Microsoft SQL Server Analysis Services: MDX ...

Optimizing Microsoft SQL Server Analysis Services: MDX Optimization Techniques: Segregating DISTINCT COUNT

By : William E. Pearson, III
Apr 22, 2004

Page 2 / 12

 

Initial Approach via MDX


Let’s initialize the MDX Sample Application, the platform from which we perform many practice exercises within the articles of our series. (We choose it because any organization that has installed MSAS has access to the Sample Application). We will create our initial query by taking the following steps:


1. Start the MDX Sample Application.


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



Figure 1: The Connect Dialog for the MDX Sample Application


The figure above depicts the name of my server, MOTHER1, and properly indicates that we will be connecting via the MSOLAP provider (the default).


2. Click OK.


The MDX Sample Application window appears.


3. Click File ---> New.


A blank Query pane appears.


4. Ensure that FoodMart 2000 is selected as the database name in the DB box of the toolbar.


5. Select the Sales cube in the Cube drop-down list box.


The MDX Sample Application window should resemble that depicted in Figure 2, complete with the information from the Sales cube displaying in the Metadata tree (left section of the Metadata pane).



Figure 2: The MDX Sample Application Window (Compressed View)


We will begin creating our query with a focus on returning results to meet the expressed business need of the information consumers. We will construct two calculated members / measures, one to contain the distinct count of the Customers, and one to calculate the average sale for each Product Category, per individual Customer. We will then SELECT the two calculated measures, presenting them to the immediate right of the Unit Sales measure for each respective Product Category.


We will retrieve a dataset with the measure / calculated measures forming the column axis, and the Product Category forming the row axis.


1. Create the following new query:

 

-- SSP11-1 Initial Attempt at Distinct Customer Dataset
 

WITH
 

   MEMBER
 

   [Measures].[Distinct Customers]
 

   AS
 

      'COUNT(CrossJoin({[Unit Sales]},


   Descendants ([Customers].CurrentMember,


  [Customers].[Name])), ExcludeEmpty)'
 

   MEMBER


   [Measures].[Avg Sales per Customer]
 

   AS


   '[Measures].[Unit Sales]/[Measures].[Distinct Customers]'


SELECT


   {[Measures].[Unit Sales], [Measures].[Distinct Customers], [Measures].

 

   [Avg Sales per Customer]} on COLUMNS,


   {[Product Category].Members} ON ROWS


FROM


  [SALES]

 

WHERE


   ([Time].[1997].[Q3])


The above represents an attempt to meet the information consumers’ objectives with what appears to be the straightforward use of the DISTINCTCOUNT() function within a calculated member, to contain the count of the distinct Customers; we then create a second calculated member based upon the first, which we divide into the Unit Sales measure to derive the Average Sales per (individual) Customer, as requested by the intended audience. We SELECT all three into the desired matrix to render the desired presentation.


<< Prev Page     Next Page>>    








Home | Peformance Articles | Audit Articles | Business Intelligence Articles | Clustering Articles | Developer Articles | Reporting Services Articles | DBA Articles | ASP.NET / ADO.NET Articles | DBA FAQ's | Developer Peformance FAQ's | DBA Peformance FAQ's | Developer FAQ's | Clustering FAQ's | Error Messages | Audit Tool Reviews | Backup Tool Reviews | Coding Tool Reviews | Compare Tool Reviews | Documentation Tool Reviews | Design Tool Reviews | Monitoring Tool Reviews | Log Tool Reviews | Reporting Tool Reviews | Clustering Tool Reviews | Security Tool Reviews | Change Management Tool Reviews | Remote Access Tool Reviews | Book Reviews | Security Tool Reviews | QDPMA Performance Tuning | ADO.NET / ASP.NET | Administration | Analysis/OLAP Services | Application Development | Configuration | Components | ETL | Hardware | High Availability | Hints | Index | Misc | Operating Systems | Performance Tuning | Replication | T-SQL | Views


              © 1999-2008 by T10 Media. All rights reserved