문제

I am developing a query builder application that generates MDX and trying to get customer counts from a cube using the following, which works just fine:

WITH MEMBER MEASURES.X AS (
    { [Customer].[Gender].[Female]}, 
    [Customer].[Customer].Children
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]

However, if the user drags in a dimension that is not related to the customer like:

WITH MEMBER MEASURES.X AS (
    { [Customer].[Gender].[Female]}, 
    { [Employee].[Status].[Active], [Employee].[Status].[Inactive]},  
    [Customer].[Customer].Children
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]

the count result obviously becomes incorrect.

Is there a way to determine whether a dimension is related to the customer so that I can exclude it from the generated MDX query?

도움이 되었습니까?

해결책 2

Solved the problem by using the Exists( Set_Expression1 , Set_Expression2 [, MeasureGroupName] ) function. No need to manually determine which dimensions are related. The Exists function filters out the unrelated tuples, leaving only the { [Customer].[Customer].Children, [Customer].[Gender].[Female]} set to do the count over.

Here is the MDX:

WITH MEMBER MEASURES.X AS Exists(
    [Customer].[Customer].Children,
    {[Customer].[Gender].[Female]}
    *
    {[Employee].[Status].[Active], [Employee].[Status].[Inactive]}
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]

다른 팁

This information can be retrieved from the cube through AMO. The Cube class contains all the cube metadata you'll need.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top