简体   繁体   English

过滤掉MDX查询中维度层次结构的特定成员

[英]Filter out a specific member of a dimension hierarchy in MDX query

I am pretty new to MDX and I have written a basic MDX query which returns a measure as well as full hierarchy of my product dimension: 我对MDX相当陌生,我编写了一个基本的MDX查询,该查询返回一个度量以及产品维度的完整层次结构:

SELECT {[Measures].[Amount]} on 0,
{
DESCENDANTS([ProductH].[ProductH], [ProductH].[ProductH].[Lvl4], LEAVES)
}
ON 1
FROM
(
  SELECT 
    {StrToSet('[AccountH].[AccountH].[Lvl1].&[TST17:0]',CONSTRAINED)} ON COLUMNS
  FROM
  (
    SELECT
      {StrToSet('[ProductH].[ProductH].[All]',CONSTRAINED)} ON COLUMNS
    FROM [Model]
  )
)

This returns the result set for my SSRS report which is basically the amount for all levels in product dimension for the user's chosen account hierarchy 这将返回我的SSRS报告的结果集,该结果集基本上是用户所选帐户层次结构的产品维度中所有级别的金额

Now, I want to exclude from this set the amounts under the 2nd level of account hierarchy with the specific name "Exclude". 现在,我要从该组中排除特定名称为“排除”的第二级帐户层次结构下的金额。 I've managed to add this filter using crossjoin and except - based on account node's unique name: 我已经设法使用crossjoin添加此过滤器,但除外-基于帐户节点的唯一名称:

[AccountH].[AccountH].[Lvl2].&[TST17:0]&[TST17:1000]

but I want specifically to filter out based on the shown name, remove amounts where: 但我要根据显示的名称专门过滤掉,删除其中的金额:

[AccountH].CURRENTMEMBER.MEMBER_CAPTION = "Exclude"

How do I filter out based on hierarchy node's name? 如何根据层次结构节点的名称过滤掉?

The Where clause must be enough: Where子句必须足够:

select
...
from [Model]
where ({[AccountH].[AccountH].Members - [AccountH].[AccountH].[Exclude]})

I've figured it out with some help, "Exclude" account nodes are not unique in the hierarchy, even on the same level (level2 for me), so apperently removing them with EXCEPT() does not work. 我已经找到了一些帮助,“ Exclude”帐户节点在层次结构中也不是唯一的,即使在同一级别上(对于我来说是level2),因此用EXCEPT()永久删除它们也不起作用。 This works however: 但是,这可行:

Filter([AccountH].[AccountH].[Lvl2]].Members
      ,[AccountH].[AccountH].CURRENTMEMBER.MEMBER_CAPTION <> "Exclude")

since it checks the name. 因为它检查名称。 But apperently the filter function is a slow one so Im going with a cross join Account * Product and then removing the "Exclude" accounts in SSRS report 但显然,筛选器功能很慢,因此我将使用交叉联接帐户*产品,然后在SSRS报告中删除“排除”帐户

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM