dbTalk Databases Forums  

HELP!!! MDX - Time hierarchy navigation

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


Discuss HELP!!! MDX - Time hierarchy navigation in the microsoft.public.sqlserver.olap forum.



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

Default HELP!!! MDX - Time hierarchy navigation - 07-25-2006 , 03:46 AM






I need to achieve something that is very simple using T-SQL, and am
vomitting blood now with MDX ... :'(

Given a date, I need to find the "First Day Two Quarters" ago,
e.g. for 25-Jul-2006, in Q3 (using Calendar Quarter), the expected
result is 01-Jan-2006 (first day of Q1 2006);
for 05-May-2006, the expected result is 01-Oct-2005.


Using Adventure Works cube, I have constructed with this MDX

Select [Measures].[Internet Sales Amount] on columns,
{ [Date].[Date].CurrentMember.Children } on rows
from [Adventure Works]
where {[Date].[Calendar].[Date].&[400].Parent.Parent.Lag(2)}

This works fine, except that it is returning all days in that Quarter.
And I trully want only the first day of that.

I have tried
- [Date].[Date].CurrentMember.Children.FirstChild
- [Date].[Date].CurrentMember.FirstChild
- [Date].[Date].CurrentMember.Children.Parent.FirstChild
- [Date].[Date].CurrentMember.Parent.FirstChild
and all failed to work.

What am I doing wrong?

thanks in advance.


Reply With Quote
  #2  
Old   
Jéjé
 
Posts: n/a

Default Re: HELP!!! MDX - Time hierarchy navigation - 07-25-2006 , 07:30 AM






Take a look at the parallelperiod function and firstsibling function.

something like:
Select [Measures].[Internet Sales Amount] on columns,

{

parallelperiod([Date].[Calendar].[Calendar Quarter]

,2,[Date].[Calendar].[Date].&[400]).firstsibling

, [Date].[Calendar].[Date].&[400]} on rows

from [Adventure Works]





"Rose" <rose.say (AT) gmail (DOT) com> wrote

Quote:
I need to achieve something that is very simple using T-SQL, and am
vomitting blood now with MDX ... :'(

Given a date, I need to find the "First Day Two Quarters" ago,
e.g. for 25-Jul-2006, in Q3 (using Calendar Quarter), the expected
result is 01-Jan-2006 (first day of Q1 2006);
for 05-May-2006, the expected result is 01-Oct-2005.


Using Adventure Works cube, I have constructed with this MDX

Select [Measures].[Internet Sales Amount] on columns,
{ [Date].[Date].CurrentMember.Children } on rows
from [Adventure Works]
where {[Date].[Calendar].[Date].&[400].Parent.Parent.Lag(2)}

This works fine, except that it is returning all days in that Quarter.
And I trully want only the first day of that.

I have tried
- [Date].[Date].CurrentMember.Children.FirstChild
- [Date].[Date].CurrentMember.FirstChild
- [Date].[Date].CurrentMember.Children.Parent.FirstChild
- [Date].[Date].CurrentMember.Parent.FirstChild
and all failed to work.

What am I doing wrong?

thanks in advance.




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

Default Re: HELP!!! MDX - Time hierarchy navigation - 07-25-2006 , 08:27 AM



You are pretty close. The problem is that the WHERE clause in MDX is
really meant to be used to filter dimensions that are not part of the
visible axis. If you want to filter the member on an axis, you would
filter them inline.

eg

Select [Measures].[Internet Sales Amount] on columns,
{[Date].[Calendar].[Date].&[400].Parent.Parent.Lag(2)} on rows
from [Adventure Works]

--
Regards
Darren Gosbell - SQL Server MVP
Blog: http://www.geekswithblogs.net/darrengosbell

In article <1153817215.507681.155640 (AT) h48g2000cwc (DOT) googlegroups.com>,
rose.say (AT) gmail (DOT) com says...
Quote:
I need to achieve something that is very simple using T-SQL, and am
vomitting blood now with MDX ... :'(

Given a date, I need to find the "First Day Two Quarters" ago,
e.g. for 25-Jul-2006, in Q3 (using Calendar Quarter), the expected
result is 01-Jan-2006 (first day of Q1 2006);
for 05-May-2006, the expected result is 01-Oct-2005.


Using Adventure Works cube, I have constructed with this MDX

Select [Measures].[Internet Sales Amount] on columns,
{ [Date].[Date].CurrentMember.Children } on rows
from [Adventure Works]
where {[Date].[Calendar].[Date].&[400].Parent.Parent.Lag(2)}

This works fine, except that it is returning all days in that Quarter.
And I trully want only the first day of that.

I have tried
- [Date].[Date].CurrentMember.Children.FirstChild
- [Date].[Date].CurrentMember.FirstChild
- [Date].[Date].CurrentMember.Children.Parent.FirstChild
- [Date].[Date].CurrentMember.Parent.FirstChild
and all failed to work.

What am I doing wrong?

thanks in advance.




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.