title: Using DateDiff in SSAS MDX
body: <p>I would like to write a KPI in SSAS which gives me back the average of all the employee's age. The employee's Birth Date is in Dim_Employee. I read 3 books full of MDX date and time handling recommendations already, but neither one worked. With hours of desperate trial and error I tried countless combination to the solution without success.</p>
  
  <p>The Birth Date is datetime(null) in the source database. The solution I tried is the following:</p>
  
  <pre><code>VBA!DateDiff("yyyy", now(), [Employee].[BirthDate].CurrentMember.Member_Value)
  </code></pre>
  
  <p>Of course I should use <code>[Date].[Date].CurrentMember</code> instead of <code>now()</code>, but for simplicity I used this.</p>
  
  <p>In the Employee dimension, I created a ValueColumn with Date datatype. When I try to execute it in Management Studio, it gives me back the following error:</p>
  
  <blockquote>
    <p>"The Axis0 function expects a tuple set expression for the argument. A
    string or numeric expression was used."</p>
  </blockquote>
  
  <p>When I do not use Member_Value, it gives back null, and DateDiff gives back <code>-2010</code>.</p>
  
  <p>Because I'm not responsible for the cube's structure where I would like to write this KPI I search for a solution which does not require new Measures, Dimensions at all. (however if there is no solution without adding new elements to the cube then I will of course propose a change request in the given cube)</p>
  
  <p>What is the solution in this case? Is it possible to write this KPI without using additional Measures?</p>