dbTalk Databases Forums  

Looking up member name corresponding to maximum value of measure

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


Discuss Looking up member name corresponding to maximum value of measure in the microsoft.public.sqlserver.olap forum.



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

Default Looking up member name corresponding to maximum value of measure - 08-29-2003 , 12:18 AM






Hi all,

Say I have a very simple cube with just one dimension, MONTH, and one
measure, UNITS_SOLD. I can use the MDX filter function to find the
maximum UNITS_SOLD across all months, but how can I find which MONTH
member that the maximum UNITS_SOLD value corresponds to?

e.g.

MONTH UNITS_SOLD
Jan 10
Feb 5
Mar 40
Apr 20

I want to create a calculated member that returns, in this case, "Mar"
as the member name which corresponds to the maximum UNITS_SOLD value
across the set.

I'd be very grateful for some pointers on how to do this as I'm
relatively new to MDX, and a bit stumped.

Thanks (in advance!)
Damian

Reply With Quote
  #2  
Old   
Lutz Morrien
 
Posts: n/a

Default Looking up member name corresponding to maximum value of measure - 08-29-2003 , 02:58 AM






Damian,
you could filter the dataset by the member you created.

Foodmart example is as follows:

WITH
MEMBER [Customers].[MaxCustomer]
as
'max(descendants([Customers].[All Customers], [Customers].
[City]))'
select hierarchize([Time].members) on 0,
{Filter(descendants([Customers].[All Customers],
[Customers].[City]), ([Customers].currentmember,[Unit
Sales])=[Customers].[MaxCustomer])} on 1
from Sales
where ([Unit Sales])

Reply With Quote
  #3  
Old   
Damian Marshall
 
Posts: n/a

Default Re: Looking up member name corresponding to maximum value of measure - 08-29-2003 , 09:57 AM



err, typo sorry, "MDX filter function" should read "MDX MAX function"

Reply With Quote
  #4  
Old   
Damian Marshall
 
Posts: n/a

Default Re: Looking up member name corresponding to maximum value of measure - 09-01-2003 , 04:24 AM



Thanks Brian, that gave me exactly the start I needed. I appreciate
you taking the time to help out.
Damian

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.