title: MDX calculation. Divide each member by grand total
body: <p><strong>SAMPLE DATA</strong></p>
  
  <p>I have exported OLAP cube in following format (Measure <code>[Some Percent]</code> usage is <code>Average over time</code>):</p>
  
  <pre><code>             [Net Weight]   [Some Percent]
               4 387          2,10%
               3 304          1,60%
  Grand total: 7 691          1,85% -- Percent is AVG
  </code></pre>
  
  <hr>
  
  <p><strong>FORMULA</strong></p>
  
  <p>I need to create new calculated member <code>[Modified Percent]</code> which should be calculated in following:</p>
  
  <pre><code>[Net Weight].[1] / [Net Weight].[Total] * [Some Percent].[1] + 
  [Net Weight].[2] / [Net Weight].[Total] * [Some Percent].[2] +
  [Net Weight].[n] / [Net Weight].[Total] * [Some Percent].[n] -- can be n rows
  </code></pre>
  
  <hr>
  
  <p><strong>FORMULA WITH SAMPLE DATA</strong></p>
  
  <p>So with my sample data will be:</p>
  
  <pre><code>4 387 / 7691 * 2,10 +   |   1,20%
  3 304 / 7691 * 1,60     |   0,69%
                      =   |   1,89% -- Sum of percent 
  </code></pre>
  
  <hr>
  
  <p><strong>DESIRED OUTPUT</strong></p>
  
  <p><code>[Modified Percent]</code> should be returned in following:</p>
  
  <pre><code>             [Net Weight]   [Some Percent]             [Modified Percent]
               4 387          2,10%                      1,20%
               3 304          1,60%                      0,69%
  Grand total: 7 691          1,85% -- Percent is AVG    1,89%
  </code></pre>
  
  <hr>
  
  <p><strong>MDX Script</strong></p>
  
  <p>For now I have <code>MDX Script</code> below, but <code>[Modified Percent]</code> returning the same values as <code>[Some Percent]</code></p>
  
  <pre><code>CREATE MEMBER CURRENTCUBE.[Measures].[Modified Percent]
   AS ([Measures].[Net Weight] / sum([Vendor Invoice].[Vendor Invoice No].[All],[Measures].[Net Weight]))  * [Measures].[Some Percent], 
  FORMAT_STRING = 'Percent', 
  NON_EMPTY_BEHAVIOR = { [Net Weight] }, 
  VISIBLE = 1;   
  </code></pre>
  
  <p>Also tried this, but unlucky, the same result too:</p>
  
  <pre><code>CREATE MEMBER CURRENTCUBE.[Measures].[Modified Percent]
   AS ([Vendor Invoice].[Vendor Invoice No].CurrentMember,[Measures].[Net Weight]) / 
       iif(
          ([Vendor Invoice].[Vendor Invoice No].CurrentMember.Parent,[Measures].[Net Weight]) = 0,
          ([Vendor Invoice].[Vendor Invoice No].CurrentMember,[Measures].[Net Weight]),
          ([Vendor Invoice].[Vendor Invoice No].CurrentMember.Parent,[Measures].[Net Weight])
          )
        * [Measures].[Some Percent], 
  FORMAT_STRING = 'Percent', 
  NON_EMPTY_BEHAVIOR = { [Net Weight] }, 
  VISIBLE = 1; 
  </code></pre>
  
  <p>Looks like divide part returning 1. Have you any ideas how to solve It? If something is unclear - ask me, I will provide more details.</p>