dbTalk Databases Forums  

aggregate and distinct count measure. Is this a bug?

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


Discuss aggregate and distinct count measure. Is this a bug? in the microsoft.public.sqlserver.olap forum.



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

Default aggregate and distinct count measure. Is this a bug? - 11-03-2005 , 07:59 AM






Hi,

Let us execute following MDX query against AW database in AS2005 build 1399
(RTM)

with
member [Product].[Product Categories].[Road and Mountain] as
aggregate([Product].[Product
Categories].[Subcategory].&[2],[Product].[Product
Categories].[Subcategory].&[1])
member [Product].[Product Categories].[Mountain and Road] as
aggregate([Product].[Product Categories].[Subcategory].&[1],
[Product].[Product Categories].[Subcategory].&[2])

select
{[Measures].[Customer Count], [Measures].[Internet Order Count]} on
columns,
{[Product].[Product Categories].[Category].&[1],
[Product].[Product Categories].[Category].&[1].children,
[Product].[Product Categories].[Road and Mountain],
[Product].[Product Categories].[Mountain and Road]
}
on rows
from [Adventure Works]The result is incredible Customer CountInternetOrder CountBikes 9,132 15,205Mountain Bikes 4,089
4,970Road Bikes 6,397 8,068Touring Bikes 2,143 2,167Road
and Mountain 4.089 4.970Mountain and Road 6.397 8.068Is it right? I
doubt it is not.Thanks,Vladimir Chtepa



Reply With Quote
  #2  
Old   
Chris Webb
 
Posts: n/a

Default RE: aggregate and distinct count measure. Is this a bug? - 11-03-2005 , 09:13 AM






Hi Vladimir,

You forgot to put curly brackets around the set inside both your Aggregate
functions! However, that doesn't mean that there isn't any weird behaviour
here. The working version of your query is:


with
member [Product].[Product Categories].[Road and Mountain] as
aggregate({[Product].[Product
Categories].[Subcategory].&[2],[Product].[Product
Categories].[Subcategory].&[1]}, MEASURES.CURRENTMEMBER)
member [Product].[Product Categories].[Mountain and Road] as
aggregate({[Product].[Product
Categories].[Subcategory].&[1],[Product].[Product
Categories].[Subcategory].&[2]}, MEASURES.CURRENTMEMBER)

select
{[Measures].[Customer Count], [Measures].[Internet Order
Count],[Measures].[Internet Sales Amount] } on columns,
{[Product].[Product Categories].[Category].&[1],
[Product].[Product Categories].[Category].&[1].children,
[Product].[Product Categories].[Road and Mountain],
[Product].[Product Categories].[Mountain and Road]
}
on rows
from [Adventure Works]

Note that you need to put in Measures.Currentmember as the second parameter
to the Aggregate function to get it to work - for some reason, without it
both calculated members return null.

HTH,

Chris

--
Blog at:
http://spaces.msn.com/members/cwebbbi/


"Vladimir Chtepa" wrote:

Quote:
Hi,

Let us execute following MDX query against AW database in AS2005 build 1399
(RTM)

with
member [Product].[Product Categories].[Road and Mountain] as
aggregate([Product].[Product
Categories].[Subcategory].&[2],[Product].[Product
Categories].[Subcategory].&[1])
member [Product].[Product Categories].[Mountain and Road] as
aggregate([Product].[Product Categories].[Subcategory].&[1],
[Product].[Product Categories].[Subcategory].&[2])

select
{[Measures].[Customer Count], [Measures].[Internet Order Count]} on
columns,
{[Product].[Product Categories].[Category].&[1],
[Product].[Product Categories].[Category].&[1].children,
[Product].[Product Categories].[Road and Mountain],
[Product].[Product Categories].[Mountain and Road]
}
on rows
from [Adventure Works]The result is incredible Customer CountInternetOrder CountBikes 9,132 15,205Mountain Bikes 4,089
4,970Road Bikes 6,397 8,068Touring Bikes 2,143 2,167Road
and Mountain 4.089 4.970Mountain and Road 6.397 8.068Is it right? I
doubt it is not.Thanks,Vladimir Chtepa




Reply With Quote
  #3  
Old   
Vladimir Chtepa
 
Posts: n/a

Default Re: aggregate and distinct count measure. Is this a bug? - 11-03-2005 , 12:53 PM



Thanks, Chris.

You have answered my second question related to second parameter in the
aggregate function.
It's strange behavior of aggreagate withou 2-nd parameter widerspricht
contradicts to the BOL.

Quote BOL
"If Numeric_Expression is not specified, this function aggregates each
measure within the current query context using the default aggregation
operator specified for each measure."

Thanks,
Vladimir Chtepa

"Chris Webb" <OnlyForPostingToNewsgroups (AT) hotmail (DOT) com> schrieb im Newsbeitrag
news:7751880B-EDDE-4EBC-A2A0-5D3666F32988 (AT) microsoft (DOT) com...
Quote:
Hi Vladimir,

You forgot to put curly brackets around the set inside both your Aggregate
functions! However, that doesn't mean that there isn't any weird behaviour
here. The working version of your query is:


with
member [Product].[Product Categories].[Road and Mountain] as
aggregate({[Product].[Product
Categories].[Subcategory].&[2],[Product].[Product
Categories].[Subcategory].&[1]}, MEASURES.CURRENTMEMBER)
member [Product].[Product Categories].[Mountain and Road] as
aggregate({[Product].[Product
Categories].[Subcategory].&[1],[Product].[Product
Categories].[Subcategory].&[2]}, MEASURES.CURRENTMEMBER)

select
{[Measures].[Customer Count], [Measures].[Internet Order
Count],[Measures].[Internet Sales Amount] } on columns,
{[Product].[Product Categories].[Category].&[1],
[Product].[Product Categories].[Category].&[1].children,
[Product].[Product Categories].[Road and Mountain],
[Product].[Product Categories].[Mountain and Road]
}
on rows
from [Adventure Works]

Note that you need to put in Measures.Currentmember as the second
parameter
to the Aggregate function to get it to work - for some reason, without it
both calculated members return null.

HTH,

Chris

--
Blog at:
http://spaces.msn.com/members/cwebbbi/


"Vladimir Chtepa" wrote:

Hi,

Let us execute following MDX query against AW database in AS2005 build
1399
(RTM)

with
member [Product].[Product Categories].[Road and Mountain] as
aggregate([Product].[Product
Categories].[Subcategory].&[2],[Product].[Product
Categories].[Subcategory].&[1])
member [Product].[Product Categories].[Mountain and Road] as
aggregate([Product].[Product Categories].[Subcategory].&[1],
[Product].[Product Categories].[Subcategory].&[2])

select
{[Measures].[Customer Count], [Measures].[Internet Order Count]} on
columns,
{[Product].[Product Categories].[Category].&[1],
[Product].[Product Categories].[Category].&[1].children,
[Product].[Product Categories].[Road and Mountain],
[Product].[Product Categories].[Mountain and Road]
}
on rows
from [Adventure Works]The result is incredible Customer
CountInternetOrder CountBikes 9,132 15,205Mountain Bikes
4,089
4,970Road Bikes 6,397 8,068Touring Bikes 2,143 2,167Road
and Mountain 4.089 4.970Mountain and Road 6.397 8.068Is it right? I
doubt it is not.Thanks,Vladimir Chtepa






Reply With Quote
  #4  
Old   
Mosha Pasumansky [MS]
 
Posts: n/a

Default Re: aggregate and distinct count measure. Is this a bug? - 11-03-2005 , 01:30 PM



Quote:
Note that you need to put in Measures.Currentmember as the second
parameter
to the Aggregate function to get it to work - for some reason, without it
both calculated members return null.
You don't need to put the second parameter to Aggregate function (in fact,
this is how almost every client tool uses it on multiselect and grouping).
The fact that it returns NULL without it - is an indication of the bug,
perhaps the same bug that Aggregate over distinct count sometimes return
wrong results in Yukon RTM. I am running SP1 version of AS, and it is fixed
there.

--
==============================*=================== =
Mosha Pasumansky - http://www.mosha.com/msolap
Analysis Services blog at http://www.sqljunkies.com/WebL*og/mosha
Development Lead in the Analysis Server team
All you need is love (John Lennon)
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.
==============================*=================== =




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.