dbTalk Databases Forums  

Two Sets on one Axis in MDX

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


Discuss Two Sets on one Axis in MDX in the microsoft.public.sqlserver.olap forum.



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

Default Two Sets on one Axis in MDX - 09-07-2005 , 11:29 AM






I am trying to generate a result set that has multiple members, from two
dimensions on a single axis. Without using a Crossjoin. Can this be
accomplished?

SET [Entities] AS '{[Entity].[State], [Entity].[State].[District]'
SET [Genders] AS '{[Gender].[All Gender].[Male], [Gender].[All
Gender].[Female]}'

Select
{[Measures].[Number of Students]} on axis(0),
NON EMPTY {[Entities], [Genders]} on axis(1)

from [SomeCube]

where (Filters Here)

tx in advance,
tim



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

Default Re: Two Sets on one Axis in MDX - 09-11-2005 , 07:43 PM






No, you cannot mix dimensions on an axis in this manner.

But you could craft the query using tuples, which I think will give you
the results you are after. Note that the dimensionality has to be the
same for every tuple in the set (ie. I specify an Entity first and then
a gender).

WITH
SET [EntityAndGender] AS '{([Entity].[State],Gender.[All Gender]),
([Entity].[State].[District],[Gender].[All Gender]),
(Entity].[All Entity],[Gender].[All Gender].[Male]),
(Entity].[All Entity],[Gender].[All Gender].[Female])}'

Select
{[Measures].[Number of Students]} on axis(0),
NON EMPTY {[EntityAndGender]} on axis(1)

from [SomeCube]

where (Filters Here)


Another possible approach is to create a series of calculated member
WITH
MEMBER Measures.[StateStudents] AS 'Sum([Entity].[State],[Measures].
[Number of Students])'
MEMBER Measures.[DistrictStudents] AS 'SUM([Entity].[State].
[DistrictMeasures].[Number of Students])'
MEMBER Measures.[MaleStudents] AS 'SUM([Gender].[All Gender].
[Male]),Measures].[Number of Students])'
MEMBER Measures.[FemaleStudents] AS 'SUM([Gender].[All Gender].
[Female],Measures].[Number of Students])'

Select
{[Measures].[StateStudents],[Measures].[DistrictStudents][Measures].
[MaleStudents][Measures].[FemaleStudents]} on axis(0),

from [SomeCube]

where (Filters Here)

Note: if you only populate a single axis it has to be axis(0) (columns)

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

In article <uSJmrl8sFHA.3864 (AT) TK2MSFTNGP12 (DOT) phx.gbl>,
tchapla (AT) nospam (DOT) turnleaf.com says...
Quote:
I am trying to generate a result set that has multiple members, from two
dimensions on a single axis. Without using a Crossjoin. Can this be
accomplished?

SET [Entities] AS '{[Entity].[State], [Entity].[State].[District]'
SET [Genders] AS '{[Gender].[All Gender].[Male], [Gender].[All
Gender].[Female]}'

Select
{[Measures].[Number of Students]} on axis(0),
NON EMPTY {[Entities], [Genders]} on axis(1)

from [SomeCube]

where (Filters Here)

tx in advance,
tim




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.