dbTalk Databases Forums  

Get "Top 10 Selling Products Last Month"

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


Discuss Get "Top 10 Selling Products Last Month" in the microsoft.public.sqlserver.olap forum.



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

Default Get "Top 10 Selling Products Last Month" - 06-18-2005 , 10:27 PM






Hi,
I can't for the life of me see what is wrong with this statement (in a
named set definition).

head(order([Product by Group].[Product].members,([Measures].[Sale
value], tail(filter([Sales Period].[Month].members, [Measures].[Sale
Value] > 0),2).item(0))
, BDESC),10)

I am trying to show the top 10 selling products last month.

I have used a filter to get only months where sales have occurred, then
the tail function to get the last 2 ie. the current month and the
previous, then the .Item(0) to get the previous month.

Unfortunately, the results aren't right, in fact I can't even see where
it gets the figures from. If I hard code the appropropriate sales
period into the MDX then it works. Also, if I use the filter directly
to retrieve the last month (on a different axis) it seems to work.

What is going on?????

Peter.


Reply With Quote
  #2  
Old   
OLAPMonkey (http://olapmonkey.blogspot.com/)
 
Posts: n/a

Default Re: Get "Top 10 Selling Products Last Month" - 06-20-2005 , 10:44 AM






Any reason you can't do something like this query I created against
Foodmart 2000?

with
set [TopProducts] as
'
TopCount(
Descendants([Product].Levels(0).Members,,Leaves),
10,
([Measures].[Unit Sales],[Time].PrevMember)
)

'
select
{
{[Measures].[Unit Sales]}
} on columns,
{
[TopProducts]
} on rows
from Sales
where([Time].[1997].[Q1].[3])

It outputs the top ten selling items from February of 1997, but showing
the sales figures for March of 1997.

- Monty


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.