Question

The children functions returns the set of the member. But I need the children of several members.

The problem is, that I can't use Union to make it work like that:

Union([Geography].[Geography].[USA].children,[Geography].[Geography].[Canada].children)

I don't know how many member it will be... So I actually would need all children of a set of members.

like:

([Geography].[Geography].[USA],[Geography].[Geography].[Canada],[Geography].[Geography].[GB]).children

Is there a function like that?


I couldn't answer my question and so I just edit it. With the help of DHN's answer and some brain work I found a solution I could use:

Except(DRILLDOWNLEVEL( {[Geography].[Geography].[USA],[Geography].[Geography].[Canada]},,0 ),
{[Geography].[Geography].[USA],[Geography].[Geography].[Canada]})

That does work for me. Explanation: I drilldown the elements the tool provides me, which returns children plus parents and then I use DHN's idea and except the parents so clean the list up a bit.

Hopefully it is understandable.

Was it helpful?

Solution 2

Well actually, you could use a Crossjoin to get the set you want.

Something like

[Geography].[Geography].[USA] * [Geography].[Geography].[Canada] * [Geography].[Geography].[GB]

But this is only a proper solution, if you have only a few different search criteria.

Alternatively, you could use Except to remove those criteria you're not interested in. E.g.

Except([Geography].[Geography].children, [Geography].[Geography].[Germany])

This would give you the whole content of the [Geography] dimension, except the one of [Germany].

Hope this helps a bit.

Edit after comment of TO

Ok, this wasn't part of your question, but I think what you need is the MemberToStr() function. Please find the doc here.

I think something like this should do the trick.

with   member [Measures].[Cities]
as     membertostr([Geography].[Geography].members.children)
select [Measures].[Cities] on 0
from   [WhatEverYourCubeNameIs]    
where  (
    [Geography].[Geography].[USA],
    [Geography].[Geography].[Canada]
)

Please note that this query is totally untested. I also may have lost some of my skills, because it's been a while, since I used . You will also have to create the query dynamically, since the selection seems to be user dependant. But I'm sure that you're aware of it. ;)

OTHER TIPS

You can use the Descendants method (the fourth form of the description linked uses a set as its first argument. Thus,

Descendants( { 
             [Geography].[Geography].[USA],
             [Geography].[Geography].[Canada],
             [Geography].[Geography].[GB]
             },
             1,
             SELF
           )

should deliver exactly what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top