title: Subtracting a calculated value from each member of a set - MDX
body: <p>I have been tasked with replacing some <code>T-SQL</code> code currently used in our reporting with it's <code>MDX</code> equivalent. I have experience with <code>T-SQL</code> but not <code>MDX</code></p>
  
  <p>I'm currently stuck on the following problem:</p>
  
  <ul>
  <li>We have a list of Stores and their Lost Sales Percentage.</li>
  <li>Each Store's Lost Sales Percentage is compared against a baseline figure for further analysis.</li>
  <li>I need to take the lowest Lost Sales Percentage value of the top quartile as a baseline figure e.g if we have 3 Stores in the top quartile, with Percentage values of 55,50,45, I would need to use 45 as the baseline figure.</li>
  <li>The baseline figure is dynamic and will change depending upon performance of all of the Stores</li>
  </ul>
  
  <p>My question is - How do I subtract the baseline figure from the list of Stores and their Lost Sales Percentage? I've attempted to do this with the following code:</p>
  
  <pre><code>WITH Member [Measures].[TopQPer] AS 
    BOTTOMCOUNT(
      TOPPERCENT(
        [Network].[Centre Id].Members, 
        25,
        [Measures].[Lost Sales Conversion Rate SSO]
      ),
      1,
      [Measures].[Lost Sales Conversion Rate SSO]
    )
  Member [Measures].[Difference] AS 
    (
      (
        [Network].[Centre Id].Members,
        [Measures].[Lost Sales Conversion Rate SSO]
      ) 
     - [Measures].[TopQPer]
    ), FORMAT_STRING = 'Percent'
  SELECT
    [Measures].[Difference] ON Columns,
    [Network].[Centre Id].MEMBERS ON ROWS
  </code></pre>