dbTalk Databases Forums  

MAX Value

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


Discuss MAX Value in the microsoft.public.sqlserver.olap forum.



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

Default MAX Value - 04-13-2006 , 11:44 AM






I have a query

SELECT

{[Measures].[Volume]} ON 0,

[Brand].[Brands].[Brand Family].ALLMEMBERS ON 1

FROM [Cube]

Which gives me

Brand A - 50
Brand B - 75
Brand C - 45
Brand D - 30

I Want an extra column that shows me the Max Value of my Answer so;

Brand A - 50 - 75
Brand B - 75 - 75
Brand C - 45 - 75
Brand D - 30 - 75

Any ideas How I do this?

Thanks

Denver


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

Default Re: MAX Value - 04-13-2006 , 03:26 PM






Depends on how generic a solution you need - here's a sample Adventure
Works query which returns the max value of the measure in the 1st
column, across all rows:

Quote:
With Member [Measures].[MaxRowVal] as
Max(StrToSet("Axis(1)"),
StrToSet("Axis(0)").Item(0))
select {[Measures].[Order Quantity],
[Measures].[MaxRowVal]} on 0,
[Product].[Product Categories].[Category].AllMembers on 1
from [Adventure Works]
---------------------------------------------------------
Order Quantity MaxRowVal
Accessories 61,931 90220
Bikes 90,220 90220
Clothing 73,598 90220
Components 49,027 90220
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


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

Default Re: MAX Value - 04-19-2006 , 03:51 AM



That doesn't seem to work, I'm happy just hard coding it in. It will
alway be the MAX of [order quantity]

Can you help?

DK


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

Default Re: MAX Value - 04-19-2006 , 09:33 AM



Well, since the query is against the standard Adventure Works cube, I'd
be curious to know what error you received
- I copied it from this thread and it seems to run fine.

You can easily modify it to "hard-code" the measure:

Quote:
With Member [Measures].[MaxRowVal] as
Max(StrToSet("Axis(1)"),
[Measures].[Order Quantity])
select {[Measures].[Order Quantity],
[Measures].[MaxRowVal]} on 0,
[Product].[Product Categories].[Category].AllMembers on 1
from [Adventure Works]
---------------------------------------------------------
Order Quantity MaxRowVal
Accessories 61,931 90,220
Bikes 90,220 90,220
Clothing 73,598 90,220
Components 49,027 90,220
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***


Reply With Quote
  #5  
Old   
Denver
 
Posts: n/a

Default Re: MAX Value - 04-19-2006 , 11:05 AM



Excuse my ignorance, this does the job nicely,

I am not using Adventure Works and was trying to get it to work with my
own database.

Thanks a lot

Denver


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.