dbTalk Databases Forums  

Distinct Count based on another measure

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


Discuss Distinct Count based on another measure in the microsoft.public.sqlserver.olap forum.



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

Default Distinct Count based on another measure - 10-03-2005 , 05:29 AM






Hi

I'm trying to perform a distinct count on the number of customers, but
only where the customers have a sales value <> 0. (e.g. if a customer
places and then cancels an order they would have a value <> 0 at a
specific point in time, but now it's zero)

The code below gives me the distinct count, but what's the syntax to
only pick up the customers where [Measures].[Sales] <> 0

WITH MEMBER
[MEASURES].[CalcCount]
AS
'COUNT(CROSSJOIN({[Measures].[Sales]}, DESCENDANTS
([Customer].CURRENTMEMBER, [Customer].[Customer Ref No])))'
SELECT
{[Measures].[Sales], [MEASURES].[CalcCount] }
ON COLUMNS,
[Customer].CHILDREN ON ROWS
FROM
[Sales]


Reply With Quote
  #2  
Old   
Andy C
 
Posts: n/a

Default Re: Distinct Count based on another measure - 10-03-2005 , 08:33 AM






Got there in the end - just had to get my filter syntax right...

WITH MEMBER
[MEASURES].[CalcCount]
AS
'COUNT(FILTER(CROSSJOIN({[Measures].[Sales]}, DESCENDANTS
([Customer].CURRENTMEMBER, [Customer].[Customer Ref
No])),[Measures].[Sales]<>0))'
SELECT
{[Measures].[Sales], [MEASURES].[CalcCount] }
ON COLUMNS,
[Customer].CHILDREN ON ROWS
FROM
[Sales]


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.