代码之家  ›  专栏  ›  技术社区  ›  Nate Anderson

MDX排除层次结构中存在值的结果

  •  3
  • Nate Anderson  · 技术社区  · 7 年前

    我有一个确定道德墙的维度。维度如下所示:

    Ethical Wall (dimension)
       --> Matter ID (hierarchy)
       --> Walled (hierarchy)
       --> White Listed Initials (hierarchy)
       --> Black Listed Initials (hierarchy)
    

    这个 [Walled]

    我已经能够相对容易地解释无墙场景和白名单场景,但我对黑名单场景有很多问题。这是我到目前为止提出的where子句:

    ({
        (
            [Ethical Wall].[Walled].&[True]
            ,[Ethical Wall].[White Listed Initials].&[XXX]
            ,[Ethical Wall].[Black Listed Initials].&[]
        )
        ,(
            [Ethical Wall].[Walled].&[True]
            ,[Ethical Wall].[White Listed Initials].&[]
            ,-{[Ethical Wall].[Black Listed Initials].&[XXX]}
        )
        ,(
            [Ethical Wall].[Walled].&[False]
            ,[Ethical Wall].[White Listed Initials].&[]
            ,[Ethical Wall].[Black Listed Initials].&[]
        )
    }) 
    

    enter image description here

    我只想选择 Ids XXX 具有访问权限。应用上面的过滤器,我得到所有3个 Ids Id 1 2 .上述文件管理器匹配如下:

    enter image description here

    为什么? 我的筛选器正在检索所有3个 Ids Ids

        ,(
            [Ethical Wall].[Walled].&[True]
            ,[Ethical Wall].[White Listed Initials].&[]
            ,-{[Ethical Wall].[Black Listed Initials].&[XXX]}
        )
    

    enter image description here

    2 回复  |  直到 7 年前
        1
  •  0
  •   whytheq    7 年前

    为什么你不能简化到这一点?

    WHERE
    ({
        (
            [Ethical Wall].[Walled].&[True]
            ,[Ethical Wall].[White Listed Initials].&[XXX]
        )
        ,(
            [Ethical Wall].[Walled].&[False]
            ,[Ethical Wall].[White Listed Initials].&[]
        )
    });
    
        2
  •  0
  •   Nate Anderson    7 年前

    我们已经找到了解决方案!!

    SET notwalled AS exists( 
           selectedmatters, 
           { 
             [Ethical Wall].[Walled].&[False] 
           } 
         ) 
      SET whitelisted AS exists( 
           selectedmatters, 
           { 
             [Ethical Wall].[White Listed Initials].&[XXX] 
           } 
         ) 
      SET blacklisted AS EXCEPT( 
           selectedmatters, 
           exists( 
             selectedmatters, 
             { 
               [Ethical Wall].[Black Listed Initials].&[XXX], 
               [Ethical Wall].[Black Listed Initials].&[] 
             } 
           ) 
         ) 
    

    然后是联合:

    UNION(notwalled, whitelisted, blacklisted) 
    

    不再为我哭泣。