dbTalk Databases Forums  

How to create a set that is filtered by a level in a dimension

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


Discuss How to create a set that is filtered by a level in a dimension in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
BRG
 
Posts: n/a

Default How to create a set that is filtered by a level in a dimension - 10-13-2005 , 05:11 PM






I'm trying to create a set of values in lower level dimension that is
filtered by the higher level dimension. For instance, I'm trying to run
the following MDX query on the Food Mart sample database:

WITH
SET [MySet] AS 'NonEmptyCrossjoin({[Customers].[State
Province].Members},{[Customers].[Country].[Canada]},1)'
SELECT [MySet] ON COLUMNS,
{[Measures].[Unit Sales]} ON ROWS
FROM Sales

I want the set MySet to include all state/provinces where the country
is equal to Canada. Note that Country is the first level in the
dimension and State Province is the second level.

The above query does not work - it always returns an empty set. How do
I fix this query to get it to work?

Thanks for your help!


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

Default Re: How to create a set that is filtered by a level in a dimension - 10-13-2005 , 08:39 PM






Are you using AS2k? I get a syntax error when trying to run your sample
as you cannot crossjoin a dimension with itself. If you are dealing with
levels in a hierarchy, the normal way of getting members from a lower
level is to use the DESCENDANTS() function.

eg.

WITH
SET [MySet] AS 'Descendants([Customers].[Country].[USA],[Customers].
[State Province])'
SELECT [MySet] ON COLUMNS,
{[Measures].[Unit Sales]} ON ROWS
FROM Sales

Your other problem is that there is not data in foodmart under Canada!


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

Reply With Quote
  #3  
Old   
BRG
 
Posts: n/a

Default Re: How to create a set that is filtered by a level in a dimension - 10-17-2005 , 12:42 PM



That works great.

Although, I think in the end I am just going to separate out the levels
into different dimensions so that I can cross-join at will. In my case
(not reflected in the sample query above) the two levels can be treated
independently even though they are related.

Thanks!


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

Default Re: How to create a set that is filtered by a level in a dimension - 10-17-2005 , 05:56 PM



Make sure you have a look at virtual dimensions, as if you are splitting
one dimension with many levels into many dimensions with one level the
performance will degrade.

If you can look into attributes in AS2k5, it sounds like they might
match exactly what you are trying to achieve.

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

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.