We have a user hierarchy
with 3 levels (Level1 being the upper level - Level3 the lower)
Using the FILTER
function I state a string, this strin
I suppose a similar query on AdventureWorks delivers what you want:
WITH
MEMBER [Measures].[LevelName] AS
[Employee].[Employee Department].CurrentMember.Level.Name
MEMBER [Measures].[LevelNumber] AS
[Employee].[Employee Department].CurrentMember.Level.Ordinal
MEMBER [Measures].[MemName] AS
[Employee].[Employee Department].CurrentMember.Name
SET [Set_TargetEmp] AS
{
FILTER(
[Employee Department].AllMembers,
(
InStr(
1,
[Employee].[Employee Department].currentmember.name,
"WC4") <> 0
)
)
}
SELECT
{
[Measures].[MemName],
[Measures].[LevelName],
[Measures].[LevelNumber]
} ON 0,
Hierarchize(
Generate([Set_TargetEmp] as e,
Ascendants(e.Current)
+
Descendants(e.Current, e.Current.Level, SELF_AND_AFTER)
)
)
ON 1
FROM [Adventure Works]
I used Hierarchize
to sort the result by hierarchy, as that seemed the most easy way for me to check the result. You may want to change that. As - in contrast to the Descendants
method - Ascendants
does not allow a set as the first argument, I used Generate
to iterate along the set. Its default behavior (without a third argument of All
), it eliminates duplicates, which I assumed is the behavior you need.