title: Calculating percentile values in SSAS
body: <p>I am trying to calculate percentile (for example 90th percentile point of my measure) in a cube and I think I am almost there. The problem I am facing is, I am able to return the row number of the 90th percentile, but do not know how to get my measure.</p>
  
  <pre><code>With
  Member [Measures].[cnt] as 
  Count(NonEmpty(
  -- dimensions to find percentile on (the same should be repeated again
  [Calendar].[Hierarchy].members * 
  [Region Dim].[Region].members * 
  [Product Dim].[Product].members
  ,
  -- add the measure to group
  [Measures].[Profit]))
  
  -- define percentile
  Member [Measures].[Percentile] as 90
  
  Member [Measures].[PercentileInt] as Int((([Measures].[cnt]) * [Measures].[Percentile]) / 100)
  
  **-- this part finds the tuple from the set based on the index of the percentile point and I am using the item(index) to get the necessary info from tuple and I am unable to get the measure part 
  Member [Measures].[PercentileLo] as
  (
  Order(
  NonEmpty(
      [Calendar].[Hierarchy].members * 
      [Region Dim].[Region].members * 
      [Product Dim].[Product].members,
      [Measures].[Profit]),
      [Measures].[Profit].Value, BDESC)).Item([Measures].[PercentileInt]).Item(3)**
  
  select
  {
  [Measures].[cnt],
  [Measures].[Percentile],[Measures].[PercentileInt],
  [Measures].[PercentileLo],
  [Measures].[Profit]
  }
  on 0
  from
  [TestData]
  </code></pre>
  
  <p>I think there must a way to get measure of a tuple found through index of a set. Please help, let me know if you need any more information. Thanks!</p>