title: Using the MDX lag and lead functions
body: <p>I'm attempting to query an SSAS cube using MDX, I have a list of numeric values which are ordered in the cube and I want to refer to an adjacent cell in the cube in order to return the value.</p>
  
  <pre><code>WITH MEMBER Measures.[LastShift]&lt;br&gt;
  AS&lt;br&gt;
  (&lt;br&gt;
      [Measures].[Impact Value GBP], &lt;br&gt;
      [Dim Shift].[Shift Value1].PrevMember&lt;br&gt;
  )&lt;br&gt;
  MEMBER Measures.[NextShift]&lt;br&gt;
  AS&lt;br&gt;
  (&lt;br&gt;
      [Measures].[Impact Value GBP], &lt;br&gt;
      [Dim Shift].[Shift Value1].NextMember&lt;br&gt;
  )&lt;br&gt;
  SELECT &lt;br&gt;
      {NONEMPTY([Measures].[Impact Value GBP]), &lt;br&gt;
      Measures.LastShift,&lt;br&gt;
      Measures.NextShift&lt;br&gt;
      }&lt;br&gt;
      ON 0,&lt;br&gt;
      NONEMPTY([Dim Shift].[Shift Value1].[Shift Value1])&lt;br&gt;
      ON 1&lt;br&gt;
  FROM [factTradeValues]&lt;br&gt;
  </code></pre>
  
  <p>I can see in the RDBMS that I do have adjacent values, but I cannot get the MDX to return anything other than null.  Maybe I'm being thick, but cannot see the solution.</p>
  
  <p>Thanks for any help</p>