dbTalk Databases Forums  

A question about AGGREGATE, levels with no (All), and #ERR

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


Discuss A question about AGGREGATE, levels with no (All), and #ERR in the microsoft.public.sqlserver.olap forum.



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

Default A question about AGGREGATE, levels with no (All), and #ERR - 08-13-2004 , 05:56 PM






Hello,

Could someone explain why the following MDX query returns #ERR (Foodmart
2000/Sales/MDX Sample App):

WITH MEMBER [Time].[Total] AS 'AGGREGATE({[Time].[Year].AllMembers})'
SELECT {[Time].[Total]}ON AXIS(0) FROM [Sales]

The Time dimension in Foodmart has no (All) level, which I suspect is the
problem. I don't really have anything to support my suspicion other than
observation. This same query run against a Time dimension with an (All)
level works correctly, as well as against non-Time dimensions with (All)
levels.

Is the lack of an (All) level the problem, or is it something else? Since
the (All) level is optional, is there something I can to in my queries to
properly aggregate in these situations?

Thanks!

Keith



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

Default Re: A question about AGGREGATE, levels with no (All), and #ERR - 08-13-2004 , 10:42 PM






The problem is that, since there is no [All] level for [Time], [Total]
is added by default at the [Year] level. In that case, using
[Year].AllMembers causes a recursive definition of [Total], since it is
a member of [Year].

By arbitrarily assigning [Total] as the child of a year, it is at the
[Quarter] level, so this version works:

Quote:
WITH MEMBER [Time].[1997].[Total] AS
'AGGREGATE({[Time].[Year].AllMembers})'
SELECT {[Time].[Total]}ON AXIS(0) FROM [Sales]
Quote:

Or .Members, rather than .AllMembers, will work as well.


- Deepak

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


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

Default Re: A question about AGGREGATE, levels with no (All), and #ERR - 08-16-2004 , 10:42 AM




Deepak,

Thanks so much for your reply! It cleared things up nicely.

Keith

"Deepak Puri" <deepak_puri (AT) progressive (DOT) com> wrote

Quote:
The problem is that, since there is no [All] level for [Time], [Total]
is added by default at the [Year] level. In that case, using
[Year].AllMembers causes a recursive definition of [Total], since it is
a member of [Year].

By arbitrarily assigning [Total] as the child of a year, it is at the
[Quarter] level, so this version works:


WITH MEMBER [Time].[1997].[Total] AS
'AGGREGATE({[Time].[Year].AllMembers})'
SELECT {[Time].[Total]}ON AXIS(0) FROM [Sales]



Or .Members, rather than .AllMembers, will work as well.


- Deepak

*** 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.