title: How to find sum of each group in Hierarchy in MDX
body: <p>In the example below I want to find sum of each group. Can someone correct my MDX query to get the desired result for GroupCount Column. </p>
  
  <pre><code>with member [GroupCount] as
  aggregate([Department].[Department ID].currentmember.parent,
            [Measures].[Pay Frequency])
  
  
  select {[Department].[Group Name].[all].children*
          [Department].[Department ID].[all].children
         } on rows,
  {[Measures].[Pay Frequency],[GroupCount]} on columns
  from test
  </code></pre>
  
  <p>The result I am getting from the above query is:</p>
  
  <p><a href="https://i.stack.imgur.com/7n1fu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7n1fu.jpg" alt="enter image description here"></a></p>
  
  <p>However I need the output as :</p>
  
  <p><a href="https://i.stack.imgur.com/hLWXZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hLWXZ.jpg" alt="enter image description here"></a></p>