dbTalk Databases Forums  

Sorting problem

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


Discuss Sorting problem in the microsoft.public.sqlserver.olap forum.



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

Default Sorting problem - 12-29-2004 , 03:58 AM






Is it possible to do a topcount or an order on two measures ?
In T-SQL we do an "order by criteria1,criteria2 etc etc"
I need to sort a set with two measures and i don't know how to do.

A good example : i do a top 30 product family on a sales cube, but i want to
see the product that have 0 in sales and have sales in the past year
So i would like to so an order by Measures.Amount,Measures.AmountY-1

Thanks a lot



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

Default Re: Sorting problem - 12-29-2004 , 05:58 PM






Here's a Foodmart Sales MDX query that effectively orders Product
Categories by [Store Sales], [Sales Q-1]. The outer Order() won't
re-order tuples with the same sort value:

Quote:
With Member [Measures].[Sales Q-1] as
'([Measures].[Store Sales], ParallelPeriod([Time].[Quarter]))'
Select {[Measures].[Store Sales], [Measures].[Sales Q-1]} on columns,
NON EMPTY Order(Order([Product].[Product Category].Members,
[Measures].[Sales Q-1], BDESC),
[Measures].[Store Sales], BDESC) on rows
from Sales
where ([Time].[1997].[Q3],[Customers].[All
Customers].[USA].[OR].[Portland] )
Quote:

- Deepak

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


Reply With Quote
  #3  
Old   
Cymryr
 
Posts: n/a

Default Re: Sorting problem - 12-30-2004 , 06:04 AM



If i understand what you say to do a topcount on two measures i must do a

head(order(order({myset},MySecondOrderCriteria,des c),MyFirstOrderCriteria,de
sc),mytopnumber)

Is it correct?
my set is a result of a crossjoin so i want to keep the hierarchie
Thanks for your answers.



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

Quote:
Here's a Foodmart Sales MDX query that effectively orders Product
Categories by [Store Sales], [Sales Q-1]. The outer Order() won't
re-order tuples with the same sort value:


With Member [Measures].[Sales Q-1] as
'([Measures].[Store Sales], ParallelPeriod([Time].[Quarter]))'
Select {[Measures].[Store Sales], [Measures].[Sales Q-1]} on columns,
NON EMPTY Order(Order([Product].[Product Category].Members,
[Measures].[Sales Q-1], BDESC),
[Measures].[Store Sales], BDESC) on rows
from Sales
where ([Time].[1997].[Q3],[Customers].[All
Customers].[USA].[OR].[Portland] )



- Deepak

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



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

Default Re: Sorting problem - 12-31-2004 , 12:06 AM



That sounds right, but I haven't tested with DESC flag.


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