2011-06-14 66 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類包含您需要的所有立方體元數據。