Using MDX to find an average for leaf members on rows...dynamically -
01-14-2004
, 03:54 PM
I am trying to find the average number of products of the set that is
on rows...dynamically.
For example, if I had states on rows and was looking at the average
number of products, I would see this
IN 72
MI 66
AL 88
Using the code below, these numbers are found by taking the average of
the number of products of the children of the members of the current
level of the current dimension. For example, the children of IN might
be Indianapolis (number products 73) and Evansville (number products
71)..and the average of these two cities' number of products is 72:
avg(Dimensions(StrToSet("Head(Axis(1))").Item(0).I tem(StrToSet("Head(Axis(1))").Item(0).Count
- 1).Dimension.Name).CurrentMember.Children, [Measures].[Number
Products])
That works great. However, what if you are at the leaf level? For
example, what if I select multiple members of the township level of
the location dimension? If I select Barr Township and LaCrosse
Township from the long list of townships of Indianapolis, and put that
on rows...what if I want to see the average of those 2 townships? For
example, when looking at the value of the number of products I see:
Barr Township 22
LaCrosse Township 44
Then when I am looking at the average number of products I want to see
this:
Barr Township 33
LaCrosee Township 33
How can I do this with MDX? |