title: MDX: dynamic named set on cubes calculation
body: <p>I am trying to create a dynamic named set that can be used in slicing data using date dimension. I want to have a several named set something like last day, last 7 days, last month, last quarter and so on. For "last day" named set, i am thinking of doing something like.</p>
  
  <pre><code>StrToMember("[Date].[Calendar].[Day].&amp;[" + DateAdd("d", -1,Tail( [Date].[Calendar].[Day], 1) + "]")
  </code></pre>
  
  <p>I want <code>DateAdd("d", -1, Tail( [Date].[Calendar].[Day], 1) + "]")</code> to return the member_value so that i can build the uniquename string to return a member, is it possible?</p>
  
  <p>The reason why I am using <code>DateAdd</code> is that, sometimes I am having a gap in my data for Day level, so using previousmember will sometimes return a wrong data.</p>
  
  <p>Ps: What I meant for the last day is not actually equal to function <code>Now()-1</code>, it is the last day that is available in the cube, that is why I cannot depend on the servers system time to achieve this.</p>