dbTalk Databases Forums  

MDX: Return the first value <=0 parent in a hieracrhy

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


Discuss MDX: Return the first value <=0 parent in a hieracrhy in the microsoft.public.sqlserver.olap forum.



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

Default MDX: Return the first value <=0 parent in a hieracrhy - 01-13-2004 , 04:16 PM






I have the following se

Y,K,M,Q,T,G,

I want to use MDX to return the name of the members parent for the first value in the set <=0 zer
for example for the following dat

Y 15
K 12
M 10
Q 9
T 7
G
W

the answer would be 'T

I have this logic in sql as a large nested if statement that basicly walks the set Y-W checking for <=0 and returns the previous value
--T SQL Cod
IF (@Yavl<=0
BEGI
SET @Class='Y
EN
ELSE IF (@Kavl<=0
BEGI
SET @Class='Y
EN
ELSE IF (@Mavl<=0
BEGI
SET @Class='K
EN
ELSE IF (@Qavl<=0
BEGI
SET @Class='M
EN
ELSE IF (@Tavl<=0
BEGI
SET @Class='Q
EN
ELSE IF (@Gavl<=0
BEGI
SET @Class='T
EN
ELSE IF (@Wavl<=0
BEGI
SET @Class='G
EN
ELS
BEGI
SET @Class='W
EN

Is there a more elegant manner to do this in MDX?

Reply With Quote
  #2  
Old   
jason
 
Posts: n/a

Default RE: MDX: Return the first value <=0 parent in a hieracrhy - 01-14-2004 , 03:56 PM






ok I have worked out an MDX method for doing this
IIF([Measures].[Yavl]<=0,[cls].[All cls].[Y].Name
IIF([Measures].[Kavl]<=0,[cls].[All cls].[Y].Name
IIF([Measures].[Mavl]<=0,[cls].[All cls].[K].Name
IIF([Measures].[Qavl]<=0,[cls].[All cls].[M].Name
IIF([Measures].[Tavl]<=0,[cls].[All cls].[Q].Name
IIF([Measures].[Gavl]<=0,[cls].[All cls].[T].Name
IIF([Measures].[Wavl]<=0,[cls].[All cls].[G].Name,[cls].[All cls].[W].Name









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.