You are very close.
Quote:
What am I not understanding???? |
What you are missing is the fact that .CurrentMember is context
sensitive. In the Generate function it is the current member from the
query. In the Filter function it is the current member from the Generate
() context.
The only way I could see to get around this was to 'trick' the MDX by
using a single member 'on the fly' set (which I could only do in a set
expression so I just unioned the member with itself). I then referenced
the first (and only) item in this set.
There is more information on this at the BI Best Practises blog
http://blogs.msdn.com/bi_systems/articles/162850.aspx
So I think your expression should look something like the one below
=========================
Sum(Generate(Descendants(UNION({[Product Categories.CurrentMember},
{[Product Categories.CurrentMember} as CURRENT_PRODUCT_SET)/item(0).Item
(0),,LEAVES) AS
GenIterator,
Head( Filter( Descendants(CURRENT_PRODUCT_SET.Item(0).Item(0),,L EAVES)
as
FilterIterator,
GenIterator.Current.item(0).Name = FilterIterator.Current.item(0).Name
), 1 ) ), [Measures].[Impact])
Below is the foodmart query I used to test this concept.
==========================
With
MEMBER Measures.x as 'Sum(Generate(Descendants(UNION
({Product.CurrentMember},{Product.CurrentMember} as CURRENTMBRSET).item
(0).item(0) ,[Product].[Brand Name]) AS GenIterator , Head( Filter(
descendants(CURRENTMBRSET.item(0).item(0),product. [Brand Name]) as
FiltIterator,
GenIterator.Current.item(0).Name = FiltIterator.Current.item(0).Name
), 1 ) ), [Measures].[Unit Sales])'
SELECT
{measures.[Unit Sales],measures.x} ON COLUMNS,
descendants([Product].[All Products],product.[brand
name],SELF_AND_BEFORE) ON ROWS
FROM sales
--
Regards
Darren Gosbell [MCSD]
<dgosbell_at_yahoo_dot_com>
Blog: http://www.geekswithblogs.net/darrengosbell