Q:

How to filter a measure based on another measure

I have a dimension table called DimUser that has 1 row per user. I have a measure based on this dimension called "USER COUNT" which is count of rows of the DimUser table. I also have a calculated measure called "ACTIVE DAYS" which returns no of days a user is active.
Now, I want to create another calculated measure based on this 2 measures, where I count only users who are active more than 5 days. I have total 5 users in my user table and 2 users in my fact table who are active more than 5 days. My MDX expression should return 2.
This is what I wrote
FILTER([Measures].[USER COUNT], [Measures].[ACTIVE DAYS] > 5)

But this gives me 5 as the answer instead of 2. What am I doing wrong?
Next I tried this, but this fails compilation saying two measures in the expression are not allowed
([Measures].[USER COUNT], [Measures].[ACTIVE DAYS] > 5)

Next, I tried creating a new calculated member called [IsActive] that returns true or false if active days > 5 and then use that as filter on the [Measures].[USER COUNT].
How do I go about doing this?

A:

To avoid using Filter which is iterative and not the best performing function. Also to create a measure that is context aware then the following might help:
WITH 
  MEMBER [Measures].[CntUsersActive5DaysOrMore] AS 
    Sum
    (
      [UserId].[UserId] //<<< or [UserId].[UserId].[UserId]
     ,IIF
      (
        [Measures].[ACTIVE DAYS] > 5
       ,1
       ,0
      )
    ) 
SELECT 
  [Measures].[CntUsersActive5DaysOrMore] ON 0
FROM [YourCube];

