MDX Query Question - Need a better way to write it. -
02-11-2004
, 05:59 PM
I have a query that will return data used in MS Reporting Services as
a flattened rowset. For this reason, I only display measures on the
column axis, and all my dimensions on the row axis.
Because I'm not an advanced MDX writer, I need some help with my
expression. If this were a SQL statement, I would have several
conditions in the WHERE clause, but I am having difficulty
understanding where to put these conditions in my MDX query.
Here is my query:
WITH
-- Only choosing 3 specific members of this dimension
SET [Delq Members] as
'{[Delq Type].[All Delq Type].[90+ Delq],
[Delq Type].[All Delq Type].[Foreclosure],
[Delq Type].[All Delq Type].[REO]}'
-- Only choosing a range of members from this dimension. I used
FILTER here as well to remove dates from another dimension, although
the use of it against this particular set is completely arbitrary, but
didn't know where in the query to apply this type of FILTER statement.
SET [MSI Members] as
'FILTER({[MSI].[All MSI].[0]:[MSI].[All MSI].[360]},
[Fund Date].CurrentMember >= [1999 Jun]) '
-- Only choosing selected members from this dimension for output.
SET [Fallout Members] as
'{[Product Desk].[NCA].[NCA AlterNet],
[Product Desk].[NCA].[NCA Exp Criteria],
[Product Desk].[Expanded Criteria].[NCA Exp Criteria],
[Product Desk].[NCA].[NCA Jumbo A],
[Product Desk].[NCA].[NCA Home Solution]}'
-- Created a set of sellers that removed two specific sellers. I do
not know how to use this set to actually remove them from the output??
SET [Sellers] as
'Except(Descendants([Sellers].[All Sellers],[Seller Name]),
{[Sellers].[All Sellers].[Homecomings Financial Network-Acc (Q72)],
[Sellers].[All Sellers].[Homecomings Financial Network- Degeorge
(T14)]})'
-- Similar to set above, only removing a single POOL ID from the Pools
dimension. Again, I do not have this constraint applied to the query
because I don't know how...
SET [Pools] as
'Except(Descendants([Deals].[All Deals],[Pool Id]),
{[Deals].[4477]})'
-- Create Calculated members using SETs created above.
Member [Measures].[Delq Agg] as
'Sum ([Delq Members],[Measures].[Prin Unpaid Bal])'
Member [Measures].[90+% Orig Sold Bal] as
'([Measures].[Delq Agg])/([Measures].[Prin Sold Bal])', format =
'#.00%'
-- Query uses the sets and calculated members above, except for the
SELLERS and POOLS sets which I don't know how to apply...
select
{[Measures].[90+% Orig Sold Bal], [Measures].[Prin Sold
Bal],[Measures].[Delq Agg]} on 0,
nonemptycrossjoin([Pmt Type].children,
nonemptycrossjoin( [Fallout Members],
nonemptycrossjoin({[Deal Vintage].[2000]:[Deal Vintage].[2002]},[MSI
Members] ))) on 1
from
cm_performance_historical
-- Once again I need to apply a constraint, so I use the WHERE clause
to filter for a specific slice of the cube.
where
([As Of].[All History],
[Deal Product].[All Deal Product].[NCA])
As you can probably see by my comments in the code, I am attempting to
bring back 4 dimensions along the row axis, and 3 measures along the
column axis. I use a combination of SETs, FILTERs, EXCEPT, and WHERE
conditions to apply the "constraints", but I didn't know the best
place to use them, and I am not even using the POOL or SELLER set
because I don't know how...
Help will be much appreciated!
Kory |