dbTalk Databases Forums  

MDX syntax

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


Discuss MDX syntax in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Truc H.
 
Posts: n/a

Default MDX syntax - 04-10-2006 , 09:12 AM






Hi MDX guru,
My fact table has 2 Dimensions [Date] and [Province] with 1 measure [Sale].
Not every date has Sale data.
I need your help to formulate a MDX (calculated member) for the following
condition:
If there is no Sale for [date].currentmember,[province].currentmember
Then: display the Sale from the most recent date where Sale is available
(remark : the most recent Date must be smaller than the selected
Date)
Else: just display current Sale

Thanks for your input.

Reply With Quote
  #2  
Old   
Darren Gosbell
 
Posts: n/a

Default Re: MDX syntax - 04-12-2006 , 06:29 AM






Something like the following will work. Note that this measure is
recursive, it refers back to itself to keep stepping back until if finds
a non-empty Sales amount.

Measures.LastSales
==================
IIF(IsEmpty(Measures.Sales),
(Date.CurrentMember.PrevMember,Measures.LastSales) ,(Measures.Sales))

It Depends a bit on the order of your time dimension. The following
query works against the Foodmart 2000 database, notice that I am using
the .NextMember function, not .Prevmember.

Quote:
WITH
MEMBER Measures.lastSales as 'IIF(IsEmpty(Measures.[Store Sales]),
(Time.CurrentMember.NextMember,Measures.LastSales) ,(Measures.[Store
Sales]))'

SELECT
{Measures.[Store Sales]
,Measures.[lastSales]} ON COLUMNS,
Time.Members ON Rows
FROM Sales
WHERE ([Promotions].[All Promotions].[Bag Stuffers])
Quote:

--
Regards
Darren Gosbell [MCSD]
Blog: http://www.geekswithblogs.net/darrengosbell

In article <C9989E26-6823-42D9-991A-B0513B58488F (AT) microsoft (DOT) com>,
TrucH (AT) discussions (DOT) microsoft.com says...
Quote:
Hi MDX guru,
My fact table has 2 Dimensions [Date] and [Province] with 1 measure [Sale].
Not every date has Sale data.
I need your help to formulate a MDX (calculated member) for the following
condition:
If there is no Sale for [date].currentmember,[province].currentmember
Then: display the Sale from the most recent date where Sale is available
(remark : the most recent Date must be smaller than the selected
Date)
Else: just display current Sale

Thanks for your input.



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.