dbTalk Databases Forums  

distinct count MDX - result is 1 more than it should be

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


Discuss distinct count MDX - result is 1 more than it should be in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
raymond via SQLMonster.com
 
Posts: n/a

Default distinct count MDX - result is 1 more than it should be - 02-21-2005 , 09:52 AM






When I try something like the below for a distinct count, I always get 1
mor than I should. Is it because of the All member? How can I set this
right?

Count(CrossJoin({measures.[dummymeasure]},
descendants([Product].[Product Name].currentmember)),excludeempty)

tia

--
Message posted via http://www.sqlmonster.com

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

Default Re: distinct count MDX - result is 1 more than it should be - 02-21-2005 , 04:41 PM






Try using:

Descendants([Product].[Product Name].CurrentMember,,LEAVES)


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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

Reply With Quote
  #3  
Old   
raymond via SQLMonster.com
 
Posts: n/a

Default Re: distinct count MDX - result is 1 more than it should be - 02-22-2005 , 06:45 AM



thank you! now it is alright.

One more question, I am using an iif to display null if value is zero -
that means i repeat the count exprssion twice. Any way I can avoid that?


iif(Count(CrossJoin({measures.[dummymeasure]},
descendants([Product].[Product Name].currentmember,, leaves)),excludeempty)
= 0,null, Count(CrossJoin({measures.[dummymeasure]},
descendants([Product].[Product Name].currentmember,, leaves)),excludeempty))

--
Message posted via http://www.sqlmonster.com

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

Default Re: distinct count MDX - result is 1 more than it should be - 02-22-2005 , 09:34 PM



You can define a second calculated measure that returns the null - can't
think of how to do it in one expression:

Quote:
With Member [Measures].[ProdCount] as
'Count(CrossJoin({measures.[dummymeasure]},
descendants([Product].[Product Name].currentmember,,
leaves)),excludeempty)'

Member [Measures].[EmptyCount] as
'iif([Measures].[ProdCount] = 0,
Null, [Measures].[ProdCount])'
Quote:

- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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