dbTalk Databases Forums  

MDX Query Syntax Performance

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


Discuss MDX Query Syntax Performance in the microsoft.public.sqlserver.olap forum.



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

Default MDX Query Syntax Performance - 09-13-2006 , 02:14 PM






I've picked this syntax up from various sources on the web to generate
an MDX query. Assuming I'm using SQL 2000 and have calculated
members/measures in the cube, is there a more efficient method or less
verbose syntax?. It works fine. I'm just curious if any of the MDX
guru's out there have a better solution.

SELECT Non Empty Head({[Gender].Members*{[Measures].[Employee
Count]}},250) ON COLUMNS,
HEAD(Filter([Employees].Children, Count( Filter({Axis(0)*
{[Ethnicity].[Hispanic]}}, NOT IsEmpty(Measures.CurrentMember)))>0
),500) ON ROWS
FROM [CubeName]
WHERE [Ethnicity].[Hispanic]


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

Default Re: MDX Query Syntax Performance - 09-14-2006 , 06:42 AM






In your row axis it is redundant to filter by axis(0) and [Ethnicity].
[Hispanic]. The context of the values in the cells that are returned
from an MDX query are the intersection of all the axis (including the
where clause) so the following query should be equivalent

SELECT
Non Empty Head({[Gender].Members},250) ON COLUMNS,
HEAD(Filter([Employees].Children, NOT IsEmpty
(Measures.CurrentMember)),500) ON ROWS
FROM [CubeName]
WHERE ([Ethnicity].[Hispanic],[Measures].[Employee Count])

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

In article <1158174865.295655.100670 (AT) p79g2000cwp (DOT) googlegroups.com>,
shovde (AT) gmail (DOT) com says...
Quote:
I've picked this syntax up from various sources on the web to generate
an MDX query. Assuming I'm using SQL 2000 and have calculated
members/measures in the cube, is there a more efficient method or less
verbose syntax?. It works fine. I'm just curious if any of the MDX
guru's out there have a better solution.

SELECT Non Empty Head({[Gender].Members*{[Measures].[Employee
Count]}},250) ON COLUMNS,
HEAD(Filter([Employees].Children, Count( Filter({Axis(0)*
{[Ethnicity].[Hispanic]}}, NOT IsEmpty(Measures.CurrentMember)))>0
),500) ON ROWS
FROM [CubeName]
WHERE [Ethnicity].[Hispanic]




Reply With Quote
  #3  
Old   
Shane
 
Posts: n/a

Default Re: MDX Query Syntax Performance - 09-14-2006 , 09:13 AM



Thanks for the response. I removed the Slicer Axis from the filter on
the Rows axis, but I found that I still need to filter on the Columns
axis to remove empties from my results. Also, there can be more than
one Measure selected, so I cannot use it in the WHERE clause.

Filter([Employees].Children, Count( Filter(Axis(0), NOT
IsEmpty(Measures.CurrentMember)))>0)
Shane

Darren Gosbell wrote:
Quote:
In your row axis it is redundant to filter by axis(0) and [Ethnicity].
[Hispanic]. The context of the values in the cells that are returned
from an MDX query are the intersection of all the axis (including the
where clause) so the following query should be equivalent

SELECT
Non Empty Head({[Gender].Members},250) ON COLUMNS,
HEAD(Filter([Employees].Children, NOT IsEmpty
(Measures.CurrentMember)),500) ON ROWS
FROM [CubeName]
WHERE ([Ethnicity].[Hispanic],[Measures].[Employee Count])

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

In article <1158174865.295655.100670 (AT) p79g2000cwp (DOT) googlegroups.com>,
shovde (AT) gmail (DOT) com says...
I've picked this syntax up from various sources on the web to generate
an MDX query. Assuming I'm using SQL 2000 and have calculated
members/measures in the cube, is there a more efficient method or less
verbose syntax?. It works fine. I'm just curious if any of the MDX
guru's out there have a better solution.

SELECT Non Empty Head({[Gender].Members*{[Measures].[Employee
Count]}},250) ON COLUMNS,
HEAD(Filter([Employees].Children, Count( Filter({Axis(0)*
{[Ethnicity].[Hispanic]}}, NOT IsEmpty(Measures.CurrentMember)))>0
),500) ON ROWS
FROM [CubeName]
WHERE [Ethnicity].[Hispanic]




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.