title: How to build a dynamic MDX formula for a calculated member?
body: <p>I am trying to create a Calculated Member to get a sum up to last week.
  No problem to get the week value (I need it to be two digits i.e. '05', so adding 100-1 )</p>
  
  <pre><code>with
  Member [Measures].Week as 
    'right(str(int(99+datepart ( ''ww'', Now()))),2)' 
  </code></pre>
  
  <p>-- That works as expected</p>
  
  <pre><code>member [Measures].SalesUpToWeek as
    'strtomember(
       "aggregate(periodstodate([Dim].[2015],[Dim].[2015].[" + ([Measures].Week) + "]),[Measures].[Sales])")'
  </code></pre>
  
  <p>I get the literal value </p>
  
  <pre><code>aggregate(
      periodstodate([Dim].[2015],[Dim].[2015].[25])
     ,[Measures].[Sales]
  )
  </code></pre>
  
  <p>What I need is the value of this <code>MDX</code> calculation.</p>
  
  <p>All other attempts end up with a syntax error. Just as an example</p>
  
  <pre><code>member [Measures].SumToWeek as 
   'aggregate(
       periodstodate(
         [Dim].[2015],[Dim].[2015].[' + strtomember([Measures].Week) + '])
     ,[Measures].[Sales])'   
  </code></pre>
  
  <p>Error  </p>
  
  <blockquote>
    <p>Lexical error at line 2, column 0. Encountered:  after : "[\n"</p>
  </blockquote>
  
  <p>Any idea?</p>