title: How to calculate average based on distinct counts in MDX
body: <p>My SSAS cube has the following fact and dimensions with the columns as shown below</p>
  
  <h2>FactActivity</h2>
  
  <p>DateKey, UserKey, ActivityKey, ActivityCount</p>
  
  <h2>DimDate</h2>
  
  <p>DateKey, Date, Week, Year</p>
  
  <h2>DimUser</h2>
  
  <p>UserKey, UserName, Gender</p>
  
  <h2>DimActivity</h2>
  
  <p>ActivityKey, ActivityName</p>
  
  <p>I have created the distinct count measures of users and dates as follows</p>
  
  <h2>[Distinct Users]</h2>
  
  <p>COUNT(NONEMPTY([DimUser].[UserKey].[UserKey].Members, [Measures].[ActivityCount])</p>
  
  <h2>[Distinct Dates]</h2>
  
  <p>COUNT(NONEMPTY([DimDate].[DateKey].[DateKey].Members, [Measures].[ActivityCount])</p>
  
  <p>Both these measures are working correctly as expected when I slice/pivot by ActivityName.</p>
  
  <p>Now I wanted to calculate average days per user, so I created the metric as follows</p>
  
  <h2>[Avg Days Per User]</h2>
  
  <p>AVG([DimUser].[UserKey].[UserKey].Members, [Measures].[Distinct Dates])</p>
  
  <p>But this is giving me wrong results.! i also tried</p>
  
  <p>DIVIDE([Measures].[Distinct Days], [Measures].[Distinct Users])</p>
  
  <p>Still I get wrong results...what i'm doing wrong? </p>