![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am trying to compute a distinct count after I have filtered out certain elements, but I can't seem to get the query right. Here's the equivalent query on the FoodMart 2000 database. I'm using Analysis Services 2000. In English, I'm trying to execute this query: "For each store type, count the number of promotions run at stores with more than 1325 sales made." Here's the query that I have now: WITH SET [SetStoreType] AS '{[Store Type].[Store Type].Members}' SET [SetPromotion] AS 'NonEmptyCrossjoin([Promotions].[Promotion Name].Members,{Filter({[Store].[Store Name].Members},[Measures].[Sales Count] >1325)},2)' MEMBER [Measures].[MyCount] AS 'DistinctCount([SetPromotion])' SELECT NON EMPTY {[Measures].[MyCount] } ON COLUMNS, NON EMPTY {SetStoreType} on rows from Sales This query produces incorrect results because I want to have a distinct count on the number of promotions, but the query gives me a distinct count on the number of promotion/store combinations. For instance, in the Small Grocery store type, the answer should be 17, but this query returns 21, since four promotions (No Promotion, One Day Sale, Super Savers, and Tip Top Savings) were run at both stores 2 and 22. However, if I change the last parameter of the NonEmptyCrossjoin to 1, in order to consolidate duplicate stores, my query no longer eliminates stores with <= 1325 in sales made. In the Small Grocery category, this means that store 14 (with sales of exactly 1325) is now included again, giving a total of 24 promotions. Again, the answer I want is 17. I've looked around the documentation for other functions to use, but I can't find something that meets my needs. Thanks for any help you can provide! |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Thanks! That query works perfectly. I didn't realize that breaking out the NonEmptyCrossjoin into the SetPromotion set was different from including it directly in the DistinctCount. I thought that the two were functionally equivalent. |

![]() |
| Thread Tools | |
| Display Modes | |
| |