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

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted Jul 5, 2006

MDX Operators: The IS Operator - Page 4

By William Pearson

Procedure: Use the IS Operator to Perform Comparisons within the FILTER() Function

The report authors / developers have an additional request which we can help them to meet with the IS operator. This time, they wish to use the Filter() function within a query which will allow them to focus upon Internet Sales at a specific geographical level. While our colleagues have asked that we craft the query to return the Internet Sales measure for customers within a single U. S. state, Georgia, for Fiscal Year 2004, we confirm their understanding that, given the core query, the capability to perform ad hoc queries, where the information consumer is prompted at runtime for a state or states (or members at other geographic levels, for that matter) becomes a simple matter of parameterizing the unique name for the state, etc., within the Filter() function we will place within the rows-axis specification of the query. Because we have demonstrated to the developers, that parameterization of this sort becomes easily attainable within Reporting Services, assuming that sufficiently sophisticated queries are put into place to support it (within either the Reporting Services or Analysis Services layers), the core query is deemed valuable to the team.

NOTE: For detailed information about the Filter() function, including practical examples that demonstrate its use, see Basic Set Functions: The Filter() Function, within my MDX Essentials series.

Having obtained consensus on the proposed target dataset, we are ready to begin constructing the query.

4.  Select File --> New from the main menu.

5.  Select Query with Current Connection from the cascading menu that appears next, as depicted in Illustration 11.


Illustration 11: Create a New Query with the Current Connection ...

A new tab, with a connection to the Adventure Works cube (we can see it listed in the selector of the Metadata pane, once again) appears in the Query pane.

6.  Type (or cut and paste) the following query into the Query pane:

-- MDX045-002-1 IS Operator within a Filter() Function
 
SELECT 
 
{[Measures].[Internet Sales Amount]} ON AXIS(0),
 
{FILTER (
 
   [Customer].[Customer Geography].MEMBERS,
    
      [Customer].[Customer Geography].CURRENTMEMBER.PARENT 
    
         IS [Customer].[Customer Geography].[State-Province].[Georgia]
   
      ) 
 
   } ON AXIS(1)
   
FROM 
 
   [Adventure Works]
 
WHERE
 
   ([Date].[Fiscal].[Fiscal Year].[FY 2004])

The Query pane appears, with our input, as shown in Illustration 12.


Illustration 12: Our Initial Query in the Query Pane ...

7.  Execute the query by clicking the Execute button in the toolbar, as before.

The Results pane is, once again, populated by Analysis Services. This time, the dataset depicted in Illustration 12 appears.


Illustration 13: Results Dataset –The Filtered Dataset is Returned ...

In the returned dataset, we see that the query appears to deliver the intended results: only those members of Customer Geography whose parent is the State-Province of Georgia (the cities of Georgia) are displayed.

8.  Select File -> Save MDXQuery2.mdx As ..., name the file MDX045-002-1.mdx, and place it in the same location used to store the earlier queries.

The effect, as we see, has been to filter the results dataset to return only those members that "pass" the conditional test enacted by the IS operator within the Filter() function. That is, only those members who return a "true" are included within the final results.

The client representatives inform us that their immediate goals have been met, and that the examples we have shared have illustrated the principles of operation behind IS operator. We discuss related matters, such as parameterization within Reporting Services, and make an appointment to return to the client site at a future date to demonstrate the concepts.

9.  Select File -> Exit to leave the SQL Server Management Studio, when ready.

Summary ...

In this article, we shifted our examination from the MDX functions, as we have upon occasion in the past, to concentrate upon an operator. We introduced the IS operator, noting that, like other logical operators, it evaluates values and returns a Boolean value. We explained that the IS operator's utility lies in its capability to perform comparisons between objects within Analysis Services.

After discussing the straightforward purpose of the IS operator, to ascertain the equivalence of two object expressions, we examined the manner in which IS manages to do this, and ways we can leverage the operator to perform efficient comparisons to meet various business needs in our own environments. Next, we examined the syntax with which we employ IS. Finally, we undertook illustrative examples whereby we put the IS operator to work, both within the definition of a calculated member and, in conjunction with the MDX Filter() function, within an axis specification of a SELECT statement, to gain some hands-on practice in its use. Throughout our practice session, we briefly discussed the results datasets we obtained from each of the queries we constructed.

» See All Articles by Columnist William E. Pearson, III

Discuss this article in the MSSQL Server 2000 Analysis Services and MDX Topics Forum.



MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




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


















Thanks for your registration, follow us on our social networks to keep up-to-date