Top member of a level? -
05-19-2005
, 06:05 AM
I am trying to get the top member of a particular level, for each
member of another dimension.
Translating this into FoodMart2000, using the sales cube, I want to get
the top selling product for each US state.
I can get the information using this query...
WITH
MEMBER [Measures].[TopProductName] as
'SetToStr(Head(Order(Filter(Descendants([product].[all products],
[product name]), [measures].[unit sales] <> 0), [measures].[unit
sales], DESC)))'
SELECT
{Descendants([Customers].[all customers].[usa], [state province])} on
rows,
{ [Measures].[TopProductName]} on columns
FROM Sales
The problem is that performance is slow (not in foodmart, but in my own
cube), and instead of just getting the product name I am getting the
complete UniqueName, complete with braces and everything. I can strip
these out in code, but I'd prefer not to have to.
I am able to get the sales amount using...
MEMBER [Product].[TopProduct] as
'Order(Filter(Descendants([product].[all products], [product name]),
[measures].[unit sales] <> 0), [measures].[unit sales], DESC).Item(0) '
MEMBER [Measures].[TopProductSales] as '([Measures].[Unit Sales],
[Product].[TopProduct])'
This works fine and performance is great when I put
[Product].[TopProduct] into the cube.
Is there a way to use the [Product].[TopProduct] member to get the name
of the top member?
Thanks,
Chris N |