title: How to view the first and/or last member values in a hierarchy
body: <p>Is there a way for me to view the first and/or last leaf value in a level of a hierarchy?</p>
  
  <p>I am trying to create a calculation dimension in SSAS which will include, for example, a year to date calculation which I would prefer not to display for dates in the future.  </p>
  
  <p>I've worked out how to make that happen at the lowest level (date), but am getting errors ath te aggregation levels when trying to implement the technique.</p>
  
  <p>To help me accomplish what I want I've included a [Date In Past] member in my dimension, which contains a 0 if the date is in the past, and a if it is not.</p>
  
  <p>For example this query, which returns calculations by date:</p>
  
  <pre><code>with member [Measures].[Year To Date] as
              Sum(
                   { IIF(strtovalue(
                          [Time Order Date].[Date In Past].Currentmember.membervalue
                                      ) = 0, null, [Measures].[Product Rev (with ship, no disc)]
                          ) } *
                     PeriodsToDate(
                                  [Time Order Date].[Fiscal Date].[Fiscal Year Name],
                                  [Time Order Date].[Fiscal Date].CurrentMember
                                   ) 
                  )
  select
  {[Measures].[Product Rev (with ship, no disc)],
  [Measures].[Year To Date]} on 0,
  [Time Order Date].[Date].Children on 1
  from [Sales Analysis]
  </code></pre>
  
  <p>returns nulls in the [Year to Date] measure for all dates in the future.</p>
  
  <p>This query, which returns calculations by the week:</p>
  
  <pre><code>with member [Measures].[Year To Date] as
              Sum(
                   { IIF(strtovalue(
                          [Time Order Date].[Date In Past].Currentmember.membervalue
                                      ) = 0, null, [Measures].[Product Rev (with ship, no disc)]
                          ) } *
                     PeriodsToDate(
                                  [Time Order Date].[Fiscal Date].[Fiscal Year Name],
                                  [Time Order Date].[Fiscal Date].CurrentMember
                                   ) 
                  )
  select
  {[Measures].[Product Rev (with ship, no disc)],
  [Measures].[Year To Date]} on 0,
  [Time Order Date].[Fiscal Week Name].Children on 1
  from [Sales Analysis]
  </code></pre>
  
  <p>returns errors for all of the [Year To Date] values, I assume because there are more than one member in the week.  </p>
  
  <p>I would like to compare it with the last day of the week.  How can I do that?</p>
  
  <p>Thanks,  --sw</p>