dbTalk Databases Forums  

Syntax for filtering on a date in MDX?

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


Discuss Syntax for filtering on a date in MDX? in the microsoft.public.sqlserver.olap forum.



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

Default Syntax for filtering on a date in MDX? - 06-17-2005 , 05:39 PM






Hello,

I'm very new to MDX (started today!) and I must be missing some very
obvious things, because I just can't figure out how to do a simple
query.

I need to figure out how to do, in MDX, the equivalent of (in tsql):

select sum(TotalSales) from Sales where DateSold > '1/1/2005'

If I can't do a "greater than" a particular date in the filter, I've
read that you can do a colon separated set like this:
[Time].[1997].[Q1].[1]:[Time].[1997].[Q1].[3]

I just can't figure out how to put it together in the mdx query.

In the MDX sample application, using the FoodMart 2000 for testing
purposes. I've tried stuff like:

SELECT
{[Measures].[Unit Sales]} ON COLUMNS
,
{Filter (
[Time].[1997].[Q1].[1]:[Time].[1997].[Q1].[3] )
} ON ROWS
FROM
[sales]

But it gives syntax errors.

Any help is much appreciated! Also any pointer to good books or
websites.

Sylvia


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

Default Re: Syntax for filtering on a date in MDX? - 06-20-2005 , 02:02 PM






I have found a way to do something like this, but it returns multiple
rows. I'd prefer to return just one row. Here's my alternative

SELECT {[Measures].[Unit Sales]} ON COLUMNs
, {[Time].[Month].[1], [Time].[Month].[2]} ON ROWS
from Sales

(In my actual cube, there's a different type of time dimension, so I
can input something like

{[Time YYMMDD].[Month].[2005 jun], [Time YYMMDD].[Month].[2005 may]}

Anyway, this is what I have now, and it works okay, I guess, just seems
clunky. I'd still appreciate any advice.

thanks!
Sylvia


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

Default Re: Syntax for filtering on a date in MDX? - 06-20-2005 , 04:18 PM



This page provides many useful links to MDX info:

http://www.mosha.com/msolap/mdx.htm


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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

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 - 2013, Jelsoft Enterprises Ltd.