SELF_BEFORE_AFTER - 为什么不返回相关级别的成员? [英] SELF_BEFORE_AFTER - why aren't members from related levels returned?
问题描述
这是我的脚本:
WITH
SET [Set_TargetEmp] AS
{
FILTER(
[Employee Department].AllMembers,
(
InStr(
1,
[Employee].[Employee Department].currentmember.name,
"REUBEN") <> 0
)
)
}
SELECT
DESCENDANTS(
[Set_TargetEmp],
[Employee].[Employee Department],
SELF_BEFORE_AFTER)
ON 1,
{} ON 0
FROM [Adventure Works]
我知道 [Set_TargetEmp]
如下:
那么为什么当我用可选的参数 SELF_BEFORE_AFTER
将它包装在函数 DESCENDANTS
中时,它不是 reuben 的相关部门和标题没有返回?
So why when I wrap it in the function DESCENDANTS
with the optional arg SELF_BEFORE_AFTER
isn't reuben's related Department and Title not returned ?
编辑
所以我进一步简化了上述内容.为什么下面不返回 Reuben 的头衔和部门 - 我认为 SELF_BEFORE_AFTER
的重点是也返回来自其他层次的亲属 [Employee].[Employee Department]代码> ?
So I've simplified the above even further. Why doesn't the following return Reuben's title and department - I thought the point of SELF_BEFORE_AFTER
was to also return relatives from the other levels of the hierarchy [Employee].[Employee Department]
?
SELECT
DESCENDANTS(
[Employee].[Employee Department].[Employee].[Reuben H. D'sa],
[Employee].[Employee Department],
SELF_BEFORE_AFTER)
ON 1,
{} ON 0
FROM [Adventure Works]
推荐答案
Descendants
只返回后代,即.e.比第一个参数低的成员.您需要的是 Ancestor
.但是 - 根据文档 - Ancestor
和 Ancestors
函数不允许将集合作为第一个参数.这意味着 - 假设您的集合可能包含多个成员 - 您必须使用 Generate
迭代[Set_TargetEmp]
的成员:
Descendants
only returns descendants, i. e. members on a lower level than the first argument. What you require would be an Ancestor
. But - according to the documentation - the Ancestor
and Ancestors
functions do not allow a set as first argument. This means that - assuming your set is meant to possibly contain more than one member - you would have to use Generate
to iterate over the members of [Set_TargetEmp]
:
WITH
SET [Set_TargetEmp] AS
{
FILTER(
[Employee Department].AllMembers,
(
InStr(
1,
[Employee].[Employee Department].currentmember.name,
"REUBEN") <> 0
)
)
}
SELECT
{} ON 0,
Generate([Set_TargetEmp] as e,
{Ancestor(e.Current, [Employee].[Employee Department].[Department])}
)
ON 1
FROM [Adventure Works]
这篇关于SELF_BEFORE_AFTER - 为什么不返回相关级别的成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!