title: Median calculated in MDX SSAS
body: <p>here is my case. I have small training in creating OLAP cube in SSAS and as part of it I need to calculate median time from creation issue to resolve issue.
  So according to microsoft docs I should use <code>MEDIAN</code> function in MDX. So here is my code:</p>
  
  <p><code>MEDIAN([Issue].[Issue ID],[Measures].[Hours Resolved])</code></p>
  
  <p>Short explanation: [Measures].[Hours Resolved] it's a measure calculated in database from dimensions "resolved issue time" - "creation issue time" with <code>DATEDIFF</code> function. Both are smalldatetime datatype.</p>
  
  <p>And it looks like it works in proper way for case on the screen below.
  Exept "Grand Total" value in Mediana column.</p>
  
  <p><a href="https://i.stack.imgur.com/BCGmZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BCGmZ.png" alt="enter image description here"></a></p>
  
  <p>I believe that Grand Total value should be 12 becasue this is proper score according to way the median should be calculated (checked also in Excel). So am I wrong here and this is proper behaviour? Or maybe I miss something in my calculation or configuration in SSAS?</p>
  
  <p>Second case in this exercise.
  When I will add for example Group Name column like on the picture below:</p>
  
  <p><a href="https://i.stack.imgur.com/htw3y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/htw3y.png" alt="enter image description here"></a></p>
  
  <p>In my understanding value mediana column for let's say CRM part should be 9.</p>
  
  <p>Can you please guide me if I'm right or wrong? If I'm right how to achieve this. Or if I'm wrong please point mistake in my solution. This is my 1st time when I'm calculating median.  </p>