title: ssas mdx query for previous previous month
body: <p>am currently building a ssas cube.  I need the default to bring back 2 periods in time.  Last month and the month prior to that.</p>
  
  <p>For last month I am using </p>
  
  <pre><code>tail(nonempty([service date].[quarter no - month no].members)) 
  </code></pre>
  
  <p>which works perfectly, however it is the previous month to this that I am struggling with.  </p>
  
  <p>Can anyone help please?  Thankyou.</p>
  
  <p>update:</p>
  
  <p>I am using this mdx as a calculation inside SSAS to then use as a filter for the dataset inside ssrs.</p>
  
  <p>My results are currently:</p>
  
  <pre><code>Contract Name   Question      TblFct     Month    Year
  -------------    -------      ------     -----    ---
  New Homes       How Many      600        Dec      2014
  </code></pre>
  
  <p>This is the number for the last month that has data in, i.e. December 2014. I am aiming to have another dataset that is automatically filtered by the same criteria but instead of the last non empty month, I am looking for the month preceeding that. I had looked at the lag function but haven't been able to make it stick for some reason.</p>
  
  <p>My comparison dataset should yield:</p>
  
  <pre><code>Contract Name   Question      TblFct     Month    Year
  -------------    -------      ------     -----    ---
  New Homes       How Many      450        Nov      2014
  </code></pre>