dbTalk Databases Forums  

Count (measure * descendants) behaviour on SSAS 2005

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


Discuss Count (measure * descendants) behaviour on SSAS 2005 in the microsoft.public.sqlserver.olap forum.



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

Default Count (measure * descendants) behaviour on SSAS 2005 - 12-15-2006 , 03:29 AM






Hi, MDX experts !

I just created calculated member on SSAS 2005, named "Distinct sold
articles". I would like to known distinct sold articles by article name and
by brand. Article name hierarchy and brand name hierarchy are in the same
dimension "Article".

When I run by article name, I get correct results, but when I run by brand,
I get the same values for all brands.

--By article description

with member [Measures].[Distinct sold articles] as
count ({[measures].[Sales qty]} * descendants ([Article].[Article
description].currentmember, [Article].[Article description].[Article
description]),excludeempty)

SELECT NON EMPTY
HIERARCHIZE(AddCalculatedMembers({DrillDownLevel({ [Article].[Article
description].[All articles]})})) DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON
COLUMNS

FROM [Sales Stock] WHERE ([Measures].[Distinct sold articles],
[Date].[Day].&[610])

--by brand name

with member [Measures].[Distinct sold articles] as
count ({[measures].[Sales qty]} * descendants ([Article].[Article
description].currentmember, [Article].[Article description].[Article
description]),excludeempty)

SELECT NON EMPTY
HIERARCHIZE(AddCalculatedMembers({DrillDownLevel({ [Article].[Brand].[All
brands]})})) DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON COLUMNS

FROM [Sales Stock] WHERE ([Measures].[Distinct sold articles],
[Date].[Day].&[610])

I would like to get number of distinct sold articles filtered by each brand.

Btw, if I run the same query in old, AS 2000, I get correct results!!! In As
2000, [article description] is a main dimension, and [Brand] is a virtual
dimension made from [article description].

Thank you!

Ramunas



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

Default Re: Count (measure * descendants) behaviour on SSAS 2005 - 12-16-2006 , 10:27 PM






Hi Ramunas,

Though I don't know the details of attribute relationships in your
[Article] dimension, this issue could be related to the attribute
overwrite behavior in SSAS calculations, as explained in this paper:

http://www.sqlserveranalysisservices...uteRelationshi
ps.htm
Quote:
...
Perhaps some explanation is required as to what exactly is an overwrite:
whenever a calculation specifies a member of a hierarchy, this is an
overwrite of the currentmember.
...
Quote:

Here's an Adventure Works query which I think illustrates your issue -
it attempts to count Products for different Styles, sold on July 1,
2002, but all counts are identical:

Quote:
with member [Measures].[Distinct Products] as
count ({[Measures].[Order Quantity]} *
descendants ([Product].[Product Categories].currentmember,
[Product].[Product Categories].[Product Name]), excludeempty)

SELECT NON EMPTY
HIERARCHIZE(AddCalculatedMembers({DrillDownLevel(
{[Product].[Style].[All Products]})}))
DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON COLUMNS
FROM [Adventure Works]
WHERE ([Measures].[Distinct Products], [Date].[Date].&[366])
------------------------------------------------------------
All Products Mens Not Applicable Unisex Womens
107 107 107 107 107
Quote:

But substituting Existing for Descndants() seems to work:

Quote:
with member [Measures].[Distinct Products] as
count ({[Measures].[Order Quantity]} *
existing [Product].[Product].[Product], excludeempty)

SELECT NON EMPTY
HIERARCHIZE(AddCalculatedMembers({DrillDownLevel(
{[Product].[Style].[All Products]})}))
DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON COLUMNS
FROM [Adventure Works]
WHERE ([Measures].[Distinct Products], [Date].[Date].&[366])
------------------------------------------------------------
All Products Mens Not Applicable Unisex Womens
107 6 26 63 12
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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


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

Default Re: Count (measure * descendants) behaviour on SSAS 2005 - 12-16-2006 , 10:30 PM



Hi Ramunas,

Though I don't know the details of attribute relationships in your
[Article] dimension, this issue could be related to the attribute
overwrite behavior in SSAS calculations, as explained in this paper:

http://www.sqlserveranalysisservices...uteRelationshi
ps.htm
Quote:
...
Perhaps some explanation is required as to what exactly is an overwrite:
whenever a calculation specifies a member of a hierarchy, this is an
overwrite of the currentmember.
...
Quote:

Here's an Adventure Works query which I think illustrates your issue -
it attempts to count Products for different Styles, sold on July 1,
2002, but all counts are identical:

Quote:
with member [Measures].[Distinct Products] as
count ({[Measures].[Order Quantity]} *
descendants ([Product].[Product Categories].currentmember,
[Product].[Product Categories].[Product Name]), excludeempty)

SELECT NON EMPTY
HIERARCHIZE(AddCalculatedMembers({DrillDownLevel(
{[Product].[Style].[All Products]})}))
DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON COLUMNS
FROM [Adventure Works]
WHERE ([Measures].[Distinct Products], [Date].[Date].&[366])
------------------------------------------------------------
All Products Mens Not Applicable Unisex Womens
107 107 107 107 107
Quote:

But substituting Existing for Descndants() seems to work:

Quote:
with member [Measures].[Distinct Products] as
count ({[Measures].[Order Quantity]} *
existing [Product].[Product].[Product], excludeempty)

SELECT NON EMPTY
HIERARCHIZE(AddCalculatedMembers({DrillDownLevel(
{[Product].[Style].[All Products]})}))
DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON COLUMNS
FROM [Adventure Works]
WHERE ([Measures].[Distinct Products], [Date].[Date].&[366])
------------------------------------------------------------
All Products Mens Not Applicable Unisex Womens
107 6 26 63 12
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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


Reply With Quote
  #4  
Old   
Ramunas Balukonis
 
Posts: n/a

Default Re: Count (measure * descendants) behaviour on SSAS 2005 - 12-18-2006 , 04:13 AM



Hi, Deepak,
yes, this is exactly what I want - existing. Thanks.

Ramunas

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

Quote:
Hi Ramunas,

Though I don't know the details of attribute relationships in your
[Article] dimension, this issue could be related to the attribute
overwrite behavior in SSAS calculations, as explained in this paper:

http://www.sqlserveranalysisservices...uteRelationshi
ps.htm

..
Perhaps some explanation is required as to what exactly is an overwrite:
whenever a calculation specifies a member of a hierarchy, this is an
overwrite of the currentmember.
..



Here's an Adventure Works query which I think illustrates your issue -
it attempts to count Products for different Styles, sold on July 1,
2002, but all counts are identical:


with member [Measures].[Distinct Products] as
count ({[Measures].[Order Quantity]} *
descendants ([Product].[Product Categories].currentmember,
[Product].[Product Categories].[Product Name]), excludeempty)

SELECT NON EMPTY
HIERARCHIZE(AddCalculatedMembers({DrillDownLevel(
{[Product].[Style].[All Products]})}))
DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON COLUMNS
FROM [Adventure Works]
WHERE ([Measures].[Distinct Products], [Date].[Date].&[366])
------------------------------------------------------------
All Products Mens Not Applicable Unisex Womens
107 107 107 107 107



But substituting Existing for Descndants() seems to work:


with member [Measures].[Distinct Products] as
count ({[Measures].[Order Quantity]} *
existing [Product].[Product].[Product], excludeempty)

SELECT NON EMPTY
HIERARCHIZE(AddCalculatedMembers({DrillDownLevel(
{[Product].[Style].[All Products]})}))
DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON COLUMNS
FROM [Adventure Works]
WHERE ([Measures].[Distinct Products], [Date].[Date].&[366])
------------------------------------------------------------
All Products Mens Not Applicable Unisex Womens
107 6 26 63 12



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