dbTalk Databases Forums  

Stumped over MDX query

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


Discuss Stumped over MDX query in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sk_rosacea@hotmail.com
 
Posts: n/a

Default Stumped over MDX query - 07-03-2005 , 01:00 PM






Hi,

I'm still a relative beginner with MDX and I was hoping that one of the
MDX experts that read this board might give me some advice on a problem
I am having.

I have got the basic query working fine, but there is subtle twist that
I can't figure out when I group the results over a particuler field.

I want to select the sum of various measures grouped over products
(with a total row) and further crossjoined over a subproperty.

i.e. something like this:

Product Property Measure1 Measure2 ...
--------------------------------------------
Total Property1 ### ###
Total Property2 ### ###
Total Property3 ### ###
Product1 Property1 ### ###
Product1 Property2 ### ###
Product1 Property3 ### ###
Product2 Property1 ### ###
Product2 Property2 ### ###
Product2 Property3 ### ###
....

Each Product has a parent ProductGroup (not shown). (There are only
two ProductGroups in total. I will call them ProductGroup1 and
ProductGroup2).

The problem I am having is that I have precalculated these measures for
different scenarios (in this case RecoveryRates if a trade were to
default) and users must select one of these scenarios for each of the
two ProductGroups which would then apply to its corresponding product
children before running the query (or else the results would be
nonsense.)

The situation is made a little more complicated because these
recoveryrate scenarios are defined along two different dimensions. One
is relative (i.e. -20%,-10%,[NoChange],+10%,+20% where [NoChange] is a
predefined recovery rate for each trade (and each trade was executed in
a particular product!) and the other dimension is in absolute terms.
(i.e. 0%,25%,50%,75%,100%). The listed absolute and relative values
are guarenteed to be calculated for each trade, but -20% could be 30%
in absolute terms so some rows will only be queried from one dimension
in the user interface and vice versa.

I would like it to be possible to give users the option to define the
recoveryrate scenario for one productgroup in absolute terms (say 0%)
and for the other productgroup in relative terms (say +20%).

I have got this working when the selection is grouped over fields other
than product, but because product is appearing in one of the selection
axes I have become confused on how to do this. Below is the query that
is closest to what I need, but produces the same output for every
product (which is wrong).

This is running scenarios absolute 0% and relative [NoChange] (i.e.
100=[NoChange])

WITH
SET [Selection] AS '{[Product].[Product].Members}'
MEMBER [Product].[TOTAL] AS 'SUM([Selection])'
MEMBER [RecoveryRate].[Filter] AS 'AGGREGATE( {
([RecoveryRate].[0],[RecoveryRateDiff].[All RecoveryRateDiff],
[Product].[ProductGroup].&[1]),
([RecoveryRate].[All RecoveryRate],[RecoveryRateDiff].[100],
[Product].[ProductGroup].&[2])
})'
SELECT Measures.Members ON COLUMNS,
NON EMPTY CROSSJOIN(
{[Product].[TOTAL],[Selection]},
[SubProperties].[SubProperty].Members) ON ROWS
FROM DefaultExposure
WHERE ([BusinessDate].[2005-06-30 00:00:00],[RecoveryRate].[Filter])

Any help on this would be really appreciated.

Thanks,
Seth


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.