dbTalk Databases Forums  

How to find the descendants of a node

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss How to find the descendants of a node in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Hichem
 
Posts: n/a

Default How to find the descendants of a node - 11-07-2004 , 10:12 PM






Hi,

If I have the following tree:

Root has children 'A' and 'B'. 'A' has children 'aa' and 'bb'. And
'B' has children 'cc' and 'dd'. And 'aa' has children 'x', 'y', and
'z'.

Now, what I need to do is get the number of descendants of any one of
these nodes in the tree at only one level below. For example, 'aa'
has 3 descendants, where as the root and 'A' has 2 each.

I have to code this using MDX in an OLAP Cube. It seems that
Descendants in MDX is always an absolute term, not relative to where
you are in the tree.

Any help would be much appreciated.

Thanks.

Hichem

Reply With Quote
  #2  
Old   
Koan B
 
Posts: n/a

Default Re: How to find the descendants of a node - 11-08-2004 , 12:43 AM






hichem.fadali (AT) td (DOT) com (Hichem) wrote in
news:ede1900e.0411072012.6e9fcdc6 (AT) posting (DOT) google.com:

<Snip>
Quote:
Now, what I need to do is get the number of descendants of any
one of these nodes in the tree at only one level below. For
example, 'aa' has 3 descendants, where as the root and 'A' has 2
each.

I have to code this using MDX in an OLAP Cube. It seems that
Descendants in MDX is always an absolute term, not relative to
where you are in the tree.

Any help would be much appreciated.
Doesn't using the distance flag of 1 give you what you need, i.e.
Count(Descendants([Your Dimension].[Your Member], 1)) ?

HTH,
Koan


Reply With Quote
  #3  
Old   
Hichem
 
Posts: n/a

Default Re: How to find the descendants of a node - 11-08-2004 , 08:24 AM



Hi,

But I thought if I used Count(Descendants([Your Dimension].[Your
Member], 1)), it's an absolute value and not relative to where I am in
the tree. For example, I thought that it would return the descendants
of the root, and not of where I am.
If my thinking is incorrect, then it's easy.

Thanks.

Hichem

Koan B <koanb (AT) newsgroups (DOT) nospam> wrote

Quote:
hichem.fadali (AT) td (DOT) com (Hichem) wrote in
news:ede1900e.0411072012.6e9fcdc6 (AT) posting (DOT) google.com:

Snip
Now, what I need to do is get the number of descendants of any
one of these nodes in the tree at only one level below. For
example, 'aa' has 3 descendants, where as the root and 'A' has 2
each.

I have to code this using MDX in an OLAP Cube. It seems that
Descendants in MDX is always an absolute term, not relative to
where you are in the tree.

Any help would be much appreciated.

Doesn't using the distance flag of 1 give you what you need, i.e.
Count(Descendants([Your Dimension].[Your Member], 1)) ?

HTH,
Koan

Reply With Quote
  #4  
Old   
Deepak Puri
 
Posts: n/a

Default Re: How to find the descendants of a node - 01-06-2005 , 11:34 PM



If you only need the number of immediate descendanst of a member node,
then (MyMember).Children.Count should work. More generally,
Descendants() also has a distance option.

From SQL Server BOL>>
Descendants

Returns the set of descendants of a member at a specified level or
distance, optionally including or excluding descendants in other levels.

Syntax

Level
Descendants(«Member», [«Level»[, «Desc_flags»]])

...

Distance
Descendants(«Member», «Distance»[, «Desc_flags»])

Returns the descendants of a member, specified by «Member», that are
«Distance» steps away in the hierarchy, optionally modified by a flag
specified in «Desc_flags». This syntax is typically used to deal with
ragged hierarchies. Specifying a «Distance» of 0 returns a set
consisting only of the member specified in «Member».
...
Quote:
- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.