Gah, if it wasn’t for those pesky business users our lives would be so much easier!
OK so if they aren’t willing to change their mind then I think we may be able to get closest value. Below is off the top of my head and I haven’t tried it but I think it’ll work.
The idea is to create a new dimension that groups the values into the percentiles, e.g. all values less then the 10% percentile are assigned value “10%”, values between the 10% and 20% percentile are assigned “20%”. Then we can use max and min functions (or maybe First and Last) to get the two values closest to the actual percentile value - max of one range and min of the next. Then determine which is closer and use that.
Start with a table of all data and initially just use one percentile - 50% say - once we get this working we can extend for all percentiles.
Add a new column and add Percentiles formula to this column and use calculation contexts so tha the percentile is calculated for the whole table and not just the row, something like:
=Percentiles([measure];0.5) In Block
Add another column and using an If formula label the rows as “0%” or “50%” if the measure value is less that the 50% percentile or not. Convert this formula to a dimension “Percentile Range”.
Add two more columns and in these use the Max function to get the max value below the 50% percentile and similarly use the Min function to get the first value above 50% percentile using the dimension we just created.
=Max([measure]) where ([Percentile Range]="0%")
=Min([measure]) where ([Percentile Range]="50%")
Now you can compare these values to the actual percentile to determine the value closest. Something like:
=if Max([measure]) where ([Percentile Range]="0%") - Percentile[measure;0.5) < Min([measure]) where ([Percentile Range]="50%") then Max([measure]) where ([Percentile Range]="0%") else Min([measure]) where ([Percentile Range]="50%")
For more than one percentiles you’ll need to use a lot of nested if statements but I think it’ll work. Once you get this working you can then remove the additional ‘working’ columns. You can probably remove the measure column and the data will aggregate up but you’ll need to keep the new [Percentile Range] dimension.
AL
agulland
(BOB member since 2004-03-17)