Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

Manipulating Many-to-many dimensions in MDX

$
0
0
Hello,

I am trying to use many-to-many relationships in Analysis Services for
the first time and therefore my question may be too basic.
And yes, I did read Marco Russo's paper on the topic.

On Adventure Works the following MDX query

SELECT [Measures].[Sales Reason Count] on 0,
NON EMPTY [Internet Sales Order Details].[Order Number].Members on 1
FROM [Adventure Works]

provides me the number of sales reasons associated to each order.

Given the hierarchy "Sales Reasons" in the "Sales Reason" dimension,
how to obtain in MDX the number of **sales reason types** associated
to each order ?

In T-SQL I obtain this using the following query

SELECT SalesOrderNumber, COUNT(DISTINCT SalesReasonReasonType)
FROM FactInternetSalesReason i, DimSalesReason d
WHERE i.SalesReasonKey = d.SalesReasonKey
GROUP BY SalesOrderNumber

In addition, how to obtain in MDX the set of Sales Reason Types
associated to each order ? For example, in the following MDX query

WITH MEMBER Measures.SalesReasonTypes AS
GENERATE([Sales Reason].[Sales Reason Type].MEMBERS,
[Sales Reason].[Sales Reason Type].CURRENTMEMBER.NAME,", ")
SELECT {[Measures].[Sales Reason Count],SalesReasonTypes} on 0,
NON EMPTY [Internet Sales Order Details].[Internet Sales Orders].[Order Number].Members on 1
FROM [Adventure Works]

I obtain for each order all the 4 sales reason types in the database, while I would
like to obtain the specific reason types associated to each order.

Many thanks for your help

Viewing all articles
Browse latest Browse all 14337

Trending Articles