dbTalk Databases Forums  

Top Count Sales + level name

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


Discuss Top Count Sales + level name in the microsoft.public.sqlserver.olap forum.



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

Default Top Count Sales + level name - 11-02-2004 , 04:11 PM






I am trying to write an MDX query that will return the top 10 products by
volumne, (lets just make it easy and say for all time) That's the easy
part. The other requirement is that I also know what "Collection" the
products is from. The product dimension is [All Products], [Collection],
[Name]

The query I have so far is:

SELECT { [Measures].[Count] } ON COLUMNS ,
{ TOPCOUNT( {Descendants( [All Products],[name]) }, 10, (
[Measures].[Count] ) ) } ON ROWS
FROM [PRODUCT_SALES]

This works great to find the top products across all collections, but I also
want the output to contain the Collection name that the product belongs to
as well......
Any Ideas????

TIA,
Scott



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

Default Re: Top Count Sales + level name - 11-03-2004 , 12:33 AM






One option is to use a text calculated measure, like:

Quote:
With [Measures].[ProductCategory] as
'Ancestor([Product].CurrentMember,
[Product].[Category]).Name'
SELECT { [Measures].[ProductCategory],
[Measures].[Count] } ON COLUMNS ,
{ TOPCOUNT( {Descendants( [All Products],[name]) },
10, ( [Measures].[Count] ) ) } ON ROWS
FROM [PRODUCT_SALES]
Quote:

- Deepak

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


Reply With Quote
  #3  
Old   
Scott Riehl
 
Posts: n/a

Default Re: Top Count Sales + level name - 11-05-2004 , 02:43 PM



That worked! It has the product name first and then collection, but I can
deal with that.....

Thanks,
BTW, I had to add the "MEMBER" clause to the first line.... like "With
Member [measures]......etc


"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote

Quote:
One option is to use a text calculated measure, like:


With [Measures].[ProductCategory] as
'Ancestor([Product].CurrentMember,
[Product].[Category]).Name'
SELECT { [Measures].[ProductCategory],
[Measures].[Count] } ON COLUMNS ,
{ TOPCOUNT( {Descendants( [All Products],[name]) },
10, ( [Measures].[Count] ) ) } ON ROWS
FROM [PRODUCT_SALES]



- 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.