dbTalk Databases Forums  

COUNT() and FILTER()

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


Discuss COUNT() and FILTER() in the microsoft.public.sqlserver.olap forum.



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

Default COUNT() and FILTER() - 01-16-2006 , 09:39 AM






I have a simple calculated member [Active Customer] defined as

COUNT(FILTER([Customer].[DIM Customer].[DIM Customer],
[Measures].[Order Count]>0))

to count the number of customers that have placed at least 1 order
before.

The FACT table (essentially a daily summary) looks like this:
Time_Key,
Customer_Key,
Product_Key
Order_Count, (this is the total order count for the day)
Order_Amount (this is the total order amount for the day)

This is working fine and it can be sliced/aggregated by Time_Key and
Product_Key, except by Customer_Key itself.

That means - when I browse on a particular day, if the [Active
Customer] is 3, it is showing

[Active Customer]
[Customer X] 3
[Customer Y] 3
[Customer Z] 3

How do I get it to return only the correct customer members showing the
correct count?


Reply With Quote
  #2  
Old   
Jéjé
 
Posts: n/a

Default Re: COUNT() and FILTER() - 01-16-2006 , 10:58 AM






try this:

COUNT(FILTER(descendants([Customer].CURRENTMEMBER, [Customer].[DIM
Customer]),
[Measures].[Order Count]>0))

or

COUNT(FILTER(descendants([Customer].CURRENTMEMBER,, leaves),
[Measures].[Order Count]>0))


"Rose" <rose.say (AT) gmail (DOT) com> wrote

Quote:
I have a simple calculated member [Active Customer] defined as

COUNT(FILTER([Customer].[DIM Customer].[DIM Customer],
[Measures].[Order Count]>0))

to count the number of customers that have placed at least 1 order
before.

The FACT table (essentially a daily summary) looks like this:
Time_Key,
Customer_Key,
Product_Key
Order_Count, (this is the total order count for the day)
Order_Amount (this is the total order amount for the day)

This is working fine and it can be sliced/aggregated by Time_Key and
Product_Key, except by Customer_Key itself.

That means - when I browse on a particular day, if the [Active
Customer] is 3, it is showing

[Active Customer]
[Customer X] 3
[Customer Y] 3
[Customer Z] 3

How do I get it to return only the correct customer members showing the
correct count?




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

Default Re: COUNT() and FILTER() - 01-16-2006 , 01:32 PM



Hi,

Do you have a AS 2005?
I woulld recommend You use distinct count measure without headache with
calculatet member.

Thahks,
Vladimir Chtepa

"Rose" <rose.say (AT) gmail (DOT) com> schrieb im Newsbeitrag
news:1137425978.766066.323450 (AT) g14g2000cwa (DOT) googlegroups.com...
Quote:
I have a simple calculated member [Active Customer] defined as

COUNT(FILTER([Customer].[DIM Customer].[DIM Customer],
[Measures].[Order Count]>0))

to count the number of customers that have placed at least 1 order
before.

The FACT table (essentially a daily summary) looks like this:
Time_Key,
Customer_Key,
Product_Key
Order_Count, (this is the total order count for the day)
Order_Amount (this is the total order amount for the day)

This is working fine and it can be sliced/aggregated by Time_Key and
Product_Key, except by Customer_Key itself.

That means - when I browse on a particular day, if the [Active
Customer] is 3, it is showing

[Active Customer]
[Customer X] 3
[Customer Y] 3
[Customer Z] 3

How do I get it to return only the correct customer members showing the
correct count?




Reply With Quote
  #4  
Old   
Rose
 
Posts: n/a

Default Re: COUNT() and FILTER() - 01-17-2006 , 12:58 AM



What I need is perhaps DISTINCTCOUNT with a condition like
Order_Count>0, because the FACT table stores a record per day per
Customer even though there are no orders for the Customer for that day:
Time_Key Customer_Key Product_Key Order_Count Order_Amount
Return_Count
100 200 40 10
10000 1
100 201 40 0
0 1
101 200 40 0
0 1
101 201 40 0
0 1

I will try using the DESDENTANTS as suggested by Jeje.


Reply With Quote
  #5  
Old   
Rose
 
Posts: n/a

Default Re: COUNT() and FILTER() - 01-17-2006 , 10:38 AM



I am getting #ERROR using

COUNT(FILTER(descendants([Customer].CURRENTMEMBER, [Customer].[DIM
Customer]),
[Measures].[Order Count]>0))
or
COUNT(FILTER(descendants([Customer].CURRENTMEMBER,, leaves),
[Measures].[Order Count]>0))

Under what conditions would they work? Does the Dimension need to have
a hierarchy?


Reply With Quote
  #6  
Old   
Rose
 
Posts: n/a

Default Re: COUNT() and FILTER() - 01-21-2006 , 08:34 PM



I am getting #ERROR with this from Adventure Works. Can someone point
out the mistake please?

WITH MEMBER [Measures].[X] AS
COUNT(FILTER(DESCENDANTS([Customer].CURRENTMEMBER,[Customer].[Customer]),[Measures].[Reseller
Order Quantity]>0))
SELECT [Measures].[X] ON COLUMNS,
DESCENDANTS([Customer].[All Customers], [Customer].[Customer
Geography].[Full Name], SELF_AND_BEFORE) ON ROWS
FROM [Adventure Works]
WHERE [Customer].[City].&[Atlanta]&[GA]


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.