views:

21

answers:

2

I have this MDX query:

Exists([Group].[Group Hierarchy].allmembers,
    {[Group].[Group Full Name].&[121 - Group A], [Group].[Group Full Name].&[700000 - Group C]})

... which works fine EXCEPT that it returns all of the ancestors of the specified groups as well. What I want is to return JUST the groups from the hierarchy with the specified Group Names (this is a type 2 dimension so there may be many at different levels).

Any ideas?

A: 

filter([Group].[Group Hierarchy].members, instr(@GroupGroupFullName,[Group].[Group Hierarchy].Properties( "Group Full Name" )))

wgpubs
A: 

I suspect that the issue is with the reference to [Group].[Group Hierarchy].allmembers. I'm guessing that [Group Hierarchy] is some sort of navigational hierarchy with multiple levels. It sounds like what you need to do is to replace [Group Hierarchy] with the name of the attribute that contains your type 2 group members in order to get a list of all the members that exist with the specified "Group Full Name" members.

I would leave Filter(..., Instr()) approach as a last resort as it would be much slower than the equivalent set based operation.

Darren Gosbell
Thanks for the comment Darren. [Group Hierarchy] is a parent-child hierarchy of a SCD Type 2 dimension ... which means that over time I have have the same Group at different levels in the hierarchy. As such, the only way I can think to identify a given Group in such an arrangement consistently is by its name (which isn't subject to a type 2 change and is unique to a given Group). I have to use the hierarchy in my query in order for all the counts and what not to add up correctly.
wgpubs
A Parent-Child hierarchy does complicate things somewhat as EXISTS will bring in all the ancestor members. Using Filter() may actually be the simplest solution in this case.
Darren Gosbell