dbTalk Databases Forums  

Filtering on different attributes in a dimension in AS2005

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Filtering on different attributes in a dimension in AS2005 in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
whbmitchell (AT) Hotmail (DOT) com
 
Posts: n/a

Default Filtering on different attributes in a dimension in AS2005 - 05-16-2006 , 07:59 PM






I have a problem coming up with an MDX statement for the following
situation.

Given the following dimension
Customer
Gender
City
JobTitle
MaritalStatus

How do I view the count of Gender by MaritalStatus where City='Seattle'
OR JobTitle='Programmer'?

in SQL I would write:
SELECT COUNT(*) FROM Customer WHERE JobTitle='Programmer' OR
City='Seattle'
GROUP BY Gender, MaritalStatus

My current solution is:

FILTER(CROSSJOIN([JobTitle].[All].Children,[City].[All].Children),
[City].MemberValue='Seattle' OR [JobTitle].MemberValue='Programmer')


Any ideas how I can improve this?


Reply With Quote
  #2  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: Filtering on different attributes in a dimension in AS2005 - 05-17-2006 , 09:10 AM






Here is an example against the Advenure Works sample database that gets
a Customer count for Marital Status = "Married" or Occupation =
"Clerical"

Quote:
SELECT
{[Measures].[Customer Count]} ON COLUMNS
FROM [Adventure Works]
WHERE
UNION({([Customer].[Marital Status].[Married]
,[Customer].[Occupation].[All Customers])}
,{([Customer].[Marital Status].[All Customers]
,[Customer].[Occupation].[Clerical])}
)
Quote:
Basically you get a set unioning Married with all occupations and
Clerical with all marital status.

--
Regards
Darren Gosbell [MCSD]
Blog: http://www.geekswithblogs.net/darrengosbell

In article <1147827597.797807.97600 (AT) y43g2000cwc (DOT) googlegroups.com>,
whbmitchell (AT) Hotmail (DOT) com says...
Quote:
I have a problem coming up with an MDX statement for the following
situation.

Given the following dimension
Customer
Gender
City
JobTitle
MaritalStatus

How do I view the count of Gender by MaritalStatus where City='Seattle'
OR JobTitle='Programmer'?

in SQL I would write:
SELECT COUNT(*) FROM Customer WHERE JobTitle='Programmer' OR
City='Seattle'
GROUP BY Gender, MaritalStatus

My current solution is:

FILTER(CROSSJOIN([JobTitle].[All].Children,[City].[All].Children),
[City].MemberValue='Seattle' OR [JobTitle].MemberValue='Programmer')


Any ideas how I can improve this?




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.