dbTalk Databases Forums  

Ordering an individual level in a crossjoined axis

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


Discuss Ordering an individual level in a crossjoined axis in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Lars-Erik Aabech
 
Posts: n/a

Default Ordering an individual level in a crossjoined axis - 03-01-2004 , 08:22 AM






Hi!

We've been struggling a lot with this one Would appreciate any pointers..

The basic query is like this:
SELECT
[Measures].[Amount] ON COLUMNS,
NON EMPTY CROSSJOIN([Time].[2003].Children, [ProductGroup].[All
ProductGroup].Children) ON ROWS
FROM
Sales

And it gives us the following grid:

Month ProductGroup Amount
Jan Group1 10
Jan Group2 30
Jan Group3 15
Feb Group1 13
Feb Group2 17

What we'd like is that the ProductGroup level is sorted by amount, while the
month level remains in its original order.

We've tried the following, but of course the hierarchy is broken across all
dimensions and not only the ProductGroup dimension:
SELECT
[Measures].[Amount] ON COLUMNS,
NON EMPTY ORDER(CROSSJOIN([Time].[2003].Children, [ProductGroup].[All
ProductGroup].Children), ([Measures].[Amount]), DESC) ON ROWS
FROM
Sales

We would like it to produce the following grid:

Month ProductGroup Amount
Jan Group2 30
Jan Group3 15
Jan Group1 10
Feb Group2 17
Feb Group1 13

We've been fooling around with the "expression" of the order function with
no success, and we've also tried to put the order function around the
[ProductGroup].[All ProductGroup].Children part of the axis specification
but then nothing happens at all.

Does anyone know if this is possible or if there is a workaround?

Lars-Erik Aabech



Reply With Quote
  #2  
Old   
Lars-Erik Aabech
 
Posts: n/a

Default Re: Ordering an individual level in a crossjoined axis - 03-01-2004 , 10:03 AM






Wouldn't that be nice?

That's exactly what I thought, but the result of the query is still
unordered if we do it.
We must be overlooking something..

Here's the exact query with norwegian names, but it should be relatively
easy to understand:
SELECT
{[Measures].[Belop]} ON COLUMNS,
NON EMPTY CROSSJOIN([Ordredato_mnd].[All Ordredato_mnd].[2003].Children,
ORDER([Produktnavn].Children, [Measures].[Belop], DESC)) ON ROWS
FROM
Salg

(Belop = Amount, Ordredato_mnd = Month, Produktnavn = Product, Salg = Sales)

It almost seems like the order function is ignored.. No syntax error, but
the list is unordered.

L-E


"Brian Altmann" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Try :

SELECT
{[Measures].[unit sales]} ON COLUMNS,
NON EMPTY CROSSJOIN([Time].[1997].Children,order( [Product].[All
Products].Children, [Measures].[unit sales] ,desc)) ON ROWS
FROM Sales

I've substituted Foodmart 2000 dimension and member names but it should be
easy to convert it back.
HTH,
Brian
www.geocities.com/brianaltmann/olap.html



Reply With Quote
  #3  
Old   
Brian Altmann
 
Posts: n/a

Default Re: Ordering an individual level in a crossjoined axis - 03-01-2004 , 11:41 AM



You're correct
It appears that the second set is evaluated once and then duplicated for each member of the first set
This syntax seems to work, there might be other alternatives

SELEC
{[Measures].[unit sales]} ON COLUMNS
NON EMPTY generate( [Time].[1997].Children ,CROSSJOIN( {time.currentmember},order( product.Children ,[measures].[unit sales],desc) )) ON ROW
FROM Sale

HTH
Brian

Reply With Quote
  #4  
Old   
Lars-Erik Aabech
 
Posts: n/a

Default Re: Ordering an individual level in a crossjoined axis - 03-01-2004 , 04:42 PM



Hmm.. it works Thanks!

I would like to know why though.. although I don't expect an answer I
understand.

L-E

"Brian Altmann" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
You're correct.
It appears that the second set is evaluated once and then duplicated for
each member of the first set.
This syntax seems to work, there might be other alternatives.

SELECT
{[Measures].[unit sales]} ON COLUMNS,
NON EMPTY generate( [Time].[1997].Children ,CROSSJOIN(
{time.currentmember},order( product.Children ,[measures].[unit
ales],desc) )) ON ROWS
Quote:
FROM Sales

HTH,
Brian



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.