Quantcast
Channel: SQL Server Analysis Services forum
Viewing all articles
Browse latest Browse all 14337

[MDX] How to cumpute a percentil (Calculated Member)

$
0
0

Let's say for a given dataset i want to calculate the percentile 0.75 this is:

Android 15
Android 9
Android 8
Android 6
Android 6
Android 5
Android 3
Android 2
iPhone 12
iPhone 10
iPhone 9
iPhone 6

Sorted by value

Android 15
iPhone 12
iPhone 10
Android 9
iPhone 9
Android 8
iPhone 6
Android 6
Android 6
Android 5
Android 3
Android 2

The percentile 0.75 for the given set is:

Andoid : 8 (index 6 of Android)
iPhone : 10 (index 3 of iPhone)
Grand Total : 9 (index 9 of all)

Now the thing is, how to compute this with a MDX query to insert on a Calculated Member (and to deploy on the cube)?

On SQL I would do the following:

1) create a set by selecting the elements the values with valid values (in my case exclude nulls)

2) Sort the set by value

3) count the set size

4) get the index of the tuple i want by multiplying the count by the percentile

5) retrieve the tuple and present the value.

How do I do this on MDX?


Viewing all articles
Browse latest Browse all 14337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>