dbTalk Databases Forums  

Comparing a Date to Time Dimension Members

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


Discuss Comparing a Date to Time Dimension Members in the microsoft.public.sqlserver.olap forum.



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

Default Comparing a Date to Time Dimension Members - 09-07-2004 , 04:39 PM






Greetings all,

In a MDX expression, During iteration through a set of the time
dimension, how can I test at each step if the current
member (Time.CurrentMember) is greater than a specified value (January
1999 for example) ?

What is the MDX syntax to perform this test ?

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

Default Re: Comparing a Date to Time Dimension Members - 09-07-2004 , 07:45 PM






This query iterates through all months in Foodmart Sales and tests
whether each month is > Sep.1997:

Quote:
select {[Measures].[Unit Sales]} on columns,
Filter([Time].[Month].Members,
Rank([Time].CurrentMember, [Time].[Month].Members) >
Rank([Time].[1997].[Q3].[9], [Time].[Month].Members)) on rows
from Sales
Quote:


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply With Quote
  #3  
Old   
Joel Cazzell
 
Posts: n/a

Default Re: Comparing a Date to Time Dimension Members - 09-14-2004 , 05:39 PM





Greetings Deepak,

Thanks for your help...I am still a little unsure about the appropriate
use of syntax.

basically what I want to accomplish is this...

iif ([Time].[Months].currentmember > 7/31/04 , <<formula>>, <<alternate
formula>>)

Would I use iif or filter and if so, what approach would you take. the
key for July 31st is 20040731.

Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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

Default Re: Comparing a Date to Time Dimension Members - 09-14-2004 , 08:04 PM



Use iif() to return numeric or text values, filter() to return an MDX
set. The actual comparison in either case can be done as in the Foodmart
Sales example, using the rank() function. The keys could be compared
directly as well.

One thing that's not clear is how a date represents a month in your case
- maybe the last date of the month is your key for that month. What are
you ultimately trying to compute?


- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #5  
Old   
Joel Cazzell
 
Posts: n/a

Default Re: Comparing a Date to Time Dimension Members - 09-14-2004 , 09:04 PM



Thanks again Deepak,

The Month of July is represented as 20040700.

I have a formula that I want to invoke on a particular measure, however
the formula changes based on time period.

I want to say:

if time.currentmember >= August 1st 2004 then Formula 1 else Formula 2.




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply With Quote
  #6  
Old   
dpuri
 
Posts: n/a

Default Re: Comparing a Date to Time Dimension Members - 09-15-2004 , 11:03 AM



Joel,

Here's a modified version of the Foddmart Sales query, which applies
different formula to months >= Aug.1997:

Quote:
With Member [Measures].[Dated Sales] as
'iif(Rank([Time].CurrentMember, [Time].[Month].Members) >=
Rank([Time].[1997].[Q3].[8], [Time].[Month].Members),
[Measures].[Unit Sales] *3, [Measures].[Unit Sales] * 2)'
Select
{[Measures].[Unit Sales], [Measures].[Dated Sales]} on columns,
Descendants([Time].[1997], [Time].[Month]) on rows
from Sales
Quote:

- Deepak

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Reply With Quote
  #7  
Old   
Joel Cazzell
 
Posts: n/a

Default Re: Comparing a Date to Time Dimension Members - 09-15-2004 , 05:01 PM




Deepak,

This was perfect!!! Makes total sense. It worked very well. Thanks
Again!!!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

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.