从不同的层次结构过滤

时间:2014-12-11 15:30:44

标签: filter mdx

如何过滤MDX查询以显示带有过滤器的多组数据 从不同的层次结构中排除某些ID号。例如下面, NOT IN部分的语法是什么?

SELECT [Measures].[Gross GAAP Par OS Amt] ON COLUMNS,
FILTER( 
   [Policy].[Policy Name].[Policy Name] * [Policy].[Policy ID].[Policy ID],
   [Policy].[Policy ID].Members
    ****NOT IN [NEW_Policy].[Policy ID].AllMembers****
)
ON ROWS
FROM EXPOSURE

谢谢!

1 个答案:

答案 0 :(得分:0)

如果它们不相关,那么我对以下内容表示怀疑,因为我认为EXCEPT的两个论点需要来自同一维度:

SELECT [Measures].[Gross GAAP Par OS Amt] ON COLUMNS,
   [Policy].[Policy Name].[Policy Name] 
   * 
   EXCEPT(
     [Policy].[Policy ID].Members,
     [NEW_Policy].[Policy ID].Members
   )
ON ROWS
FROM EXPOSURE

EDIT。 (显然未经测试 - 如果转移到AdvWks示例,那么更容易测试)

另一次尝试,这比sql更复杂:

WITH 
   MEMBER [Measures].[PolicyName] AS
     [Policy].[Policy ID].currentmember.membervalue
   MEMBER [Measures].[NEWPolicyName] AS
     [NEW_Policy].[Policy ID].currentmember.membervalue
   MEMBER [Measures].[DoTheyMatch] AS
     iif(
       [Measures].[PolicyName] = [Measures].[NEWPolicyName]
       ,1 
       ,null
     )  
   SET [MATCHES] AS
     NONEMPTY(
       [Policy].[Policy ID].Members
       *
       [NEW_Policy].[Policy ID].Members
       , [Measures].[DoTheyMatch]  
     )    
SELECT 
   [Measures].[Gross GAAP Par OS Amt] 
 ON 0,
   [Policy].[Policy Name].[Policy Name] 
   * 
   EXCEPT(
     [Policy].[Policy ID].Members * [NEW_Policy].[Policy ID].Members,
     [MATCHES]
   )
 ON 1
FROM EXPOSURE