Wednesday, March 7, 2012

How "WHERE" clause can be used in MDX query?

Hi,

I am writing MDX query to retrive a set of data based on selected range of date.

I have written a MDX query but it is not filtering .

My code:

SELECT NON EMPTY { [Measures].[Fact Table Count] } ON COLUMNS, NON EMPTY topcount({ ([Date Time1].[Date Time1].[Date Time1].ALLMEMBERS ) } ,1000)DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( [Date Time1].[Date Time1].&[2006-01-25T05:53:07] : [Date Time1].[Date Time1].&[2006-02-25T15:53:56] ) ON COLUMNS FROM [Cube Analysis]) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

This code should display only data with selected range of date but it displaying all data.

Can any one give a solution to filter the data based on Date using WHERE clause.

Thank you.

The subcube filter looks fine. Can you repro this against the Adventure Works cube?|||

Try this

with member [Measures].[FILTERBYTIME] AS

SUM(

CROSSJOIN(

[Measures].[Fact Table Count],

[Date Time1].[Date Time1].&[2006-01-25T05:53:07] : [Date Time1].[Date Time1].&[2006-02-25T15:53:56]

)

)

SELECT

NON EMPTY { [Measures].[FILTERBYTIME] } ON COLUMNS,

NON EMPTY topcount(

{

([Date Time1].[Date Time1].[Date Time1].ALLMEMBERS )

} ,1000

)DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Cube Analysis] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

or try this one.

SELECT

NON EMPTY

{ [Measures].[Fact Table Count] } ON COLUMNS,

NON EMPTY topcount(

{

([Date Time1].[Date Time1].[Date Time1].ALLMEMBERS )

} ,1000

)DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Cube Analysis]

where

{

[Date Time1].[Date Time1].&[2006-01-25T05:53:07] : [Date Time1].[Date Time1].&[2006-02-25T15:53:56]

}

CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

No comments:

Post a Comment