dbTalk Databases Forums  

Getting Measure Total Without One Dimension Value (EXCEPT?)

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


Discuss Getting Measure Total Without One Dimension Value (EXCEPT?) in the microsoft.public.sqlserver.olap forum.



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

Default Getting Measure Total Without One Dimension Value (EXCEPT?) - 01-25-2006 , 02:33 PM






I'm running into a problem computing a measure total. Instead of
computing the measure across all values in the dimension or individual
values in the dimension I'd like to compute it across a subset of the
values in the dimension. For example, if I have a time dimension I'd
like to be able to compute the values for January and February without
March. It appears that EXCEPT should allow me to do that but it simply
leaves out one of the dimension values from the result set and then
returns the full total.

One workaround that I came up with was to create a hierarchy for the
dimension by introducing a snowflake dimension: "Dimension Group" would
contain the individual members of "Dimension" and also include the
subsets I wanted. However, this is very messy and doesn't work well for
all dimensions. Is there another way to do this with MDX?

Thanks,
Kevin.

Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: Getting Measure Total Without One Dimension Value (EXCEPT?) - 01-25-2006 , 06:47 PM






Will VisualTotals() serve your purpose, like:

Quote:
select {[Measures].[Unit Sales]} on 0,
VisualTotals(Except(
Descendants([Time].[1997].[Q1]),
{[Time].[1997].[Q1].[3]})) on 1
from Sales
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


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

Default Re: Getting Measure Total Without One Dimension Value (EXCEPT?) - 01-26-2006 , 10:09 AM



Deepak Puri wrote:
Quote:
Will VisualTotals() serve your purpose, like:

select {[Measures].[Unit Sales]} on 0,
VisualTotals(Except(
Descendants([Time].[1997].[Q1]),
{[Time].[1997].[Q1].[3]})) on 1
from Sales
Thanks, while I was waiting for a reply I found this solution:

WITH MEMBER [Time].[1997].[Q1 Jan and Feb]
'[Time].[1997].[Q1].[1] + [Time].[1997].[Q1].[2]'
SELECT {[Measures].[Unit Sales]} ON COLUMNS,
{[Time].[1997].[Q1].[1], [Time].1997.[Q1].[2],
[Time].[1997].[Q1 Jan and Feb]} ON ROWS
FROM [Sales]


Is VisualTotals better or is my solution essentially the same thing?
They seem to come up with the same results...

Thanks,
Kevin.


Reply With Quote
  #4  
Old   
Deepak Puri
 
Posts: n/a

Default Re: Getting Measure Total Without One Dimension Value (EXCEPT?) - 01-26-2006 , 05:51 PM



Hi Kevin,

It depends on your scenario - VisualTotals() substitutes the necessary
calculated members dynamically, so no calculated members need to be
explicitly created.


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***

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.