title: MDX Add Calculated Member For Average
body: <p>I have a working query I would like to change a little bit.</p>
  
  <p>The working query gives me a calculated measure value for each campaign that a user has participated in.</p>
  
  <p>Since in this query example, there are 2 calculated values 0, and 7 each for the 2 campaigns this user participated in, I should be able to convert the query to display a single user row with the average of the two values, e.g. 3.5 .</p>
  
  <p>That's where I'm stuck. Does anyone know how to add-replace the [Day Diff Exposure to Download] in the results to an [Avg Day Diff...] calculation?</p>
  
  <p>Thank you very much for your help.</p>
  
  <p>Here is the original working query:</p>
  
  <pre><code>with
  member [measures].FirstEventDate as CDate(Head(NonEmpty([DIM DATE].[Date].[Date], ([Measures].[Count], [DIM USER].[Email].CurrentMember, [DIM CAMPAIGN].[Campaign].CurrentMember))).item(0).member_caption)
  member [measures].[Day Diff Exposure to Download] as ([DIM EVENT].[Event].[Event Name].&amp;[download], [measures].FirstEventDate) - ([DIM EVENT].[Event].[Event Name].&amp;[exposure], [measures].FirstEventDate)
  select
  [measures].[Day Diff Exposure to Download] on columns,
  NonEmpty (
      {([DIM USER].[Email].[User Email].&amp;[100000@mail.com],
      [DIM CAMPAIGN].[CampaignTypeName].[Campaign Name])},
      [DIM EVENT].[Event].[Event Name].&amp;[download]
  ) on rows
  from [MyCube]
  </code></pre>
  
  <p>Here is my currently unsuccessful attempt to upgrade the query:</p>
  
  <pre><code>with
  member [measures].FirstEventDate as CDate(Head(NonEmpty([DIM DATE].[Date].[Date], ([Measures].[Count], [DIM USER].[Email].CurrentMember, [DIM CAMPAIGN].[Campaign].CurrentMember))).item(0).member_caption)
  member [measures].[Day Diff Exposure to Download] as ([DIM EVENT].[Event].[Event].&amp;[download], [measures].FirstEventDate) - ([DIM EVENT].[Event].[Event].&amp;[exposure], [measures].FirstEventDate)
  member [measures].[Avg Day Diff] as
  Avg(
      NonEmpty(
          {[DIM CAMPAIGN].[Campaign].[Campaign]},
          (
              [DIM USER].[Email].CurrentMember,
              [DIM EVENT].[Event].[Event].&amp;[download]
          )
      ),
      [measures].[Day Diff Exposure to Download]
  )
  select
  [measures].[measures].[Avg Day Diff] on columns,
  NonEmpty (
      {[DIM USER].[Email].[Email].&amp;[100000@mail.com]},
      [DIM EVENT].[Event].[Event].&amp;[download]
  ) on rows
  from [MyCube]
  </code></pre>
  
  <p>Unfortunately for now, the attempted query doesn't return the value 3.5, but returns -13738.3333333 instead.</p>