2011-06-14 46 views
0

我发展产生MDX查询生成器应用程序并尝试使用以下,这只是罚款从立方体得到客户数:如何确定尺寸是否相关?

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

但是,如果用户在一个维度是不相关的拖累给客户如:

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] 

计数结果明显变得不正确。

有没有方法可以确定维度是否与客户相关,以便我可以从生成的MDX查询中排除它?

回答

1

通过使用Exists(Set_Expression1 , Set_Expression2 [, MeasureGroupName])函数解决了该问题。无需手动确定哪些尺寸是相关的。 Exists函数可以过滤出不相关的元组,只留下设置的计数结束的 { [Customer].[Customer].Children, [Customer].[Gender].[Female]}

这里是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] 
1

该信息可以通过AMO从立方体检索。 Cube类包含您需要的所有立方体元数据。