
1. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Ramon Martinez Jul 24, 2014 4:47 PM (in response to Ademola Okuneye)Hi Ademola,
To get and answer to your question, I suggest you to share a sample data set to replicate your results and find the reason of the difference you have found..
Best
Ramon

2. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Ademola Okuneye Jul 24, 2014 6:12 PM (in response to Ramon Martinez)Hi Ramon,
I have attached the sample data (twbx & excel) which shows the results I'm getting.
Thanks for you help!

3. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Matt Lutton Jul 25, 2014 6:40 AM (in response to Ademola Okuneye)Jim Wahl has written about Percentiles lately, and I wonder if he might have a clue as to why Tableau is computing this differently. I tried several approaches, but could never get the values to match your Excel file. I assume Excel is computing the Percentile using a different method, but I'm not exactly sure.
Hope to see a solution from someone soon!

4. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Michael Boldin Jul 25, 2014 7:15 AM (in response to Ademola Okuneye)1 of 1 people found this helpfulLook at the difference between Excel's PERCENTILE.EXC and PERCENTILE.INC functions
I believe PERCENTILE is the Inclusive type (INC).
In essence, where there are 'ties' and the percentile breakpoints do not perfectly split the data, percentile calculations have a degree of ambiguity that depends on how you count and use the 'last' and 'next' value around the percentile split.
FYI your table in the posting and the EXCEL file do not agree exactly. See Group C

5. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Ademola Okuneye Jul 25, 2014 7:01 AM (in response to Michael Boldin)Thanks  I'm hoping someone has been able to replicate the PERCENTILE.INC function in Tableau

6. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Matt Lutton Jul 25, 2014 7:03 AM (in response to Michael Boldin)Is there a trick to using Percentile.EXC in Excel? I'm unable to use itdid it show up in 2010?

7. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Michael Boldin Jul 25, 2014 7:33 AM (in response to Matt Lutton)Microsoft documentation says EXCEL 2010. I believe a large number of extra .xxx functions were added in 2010 to fix problems with various EXCEL statistics calculations and handle ambiguities like this one (Google: "Friends don't let friends do statistics in EXCEL").

8. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Michael Boldin Jul 25, 2014 7:39 AM (in response to Ademola Okuneye)But EXCEL's PERCENTILE calculation might be wrong (or at least unconventional)!
Not sure if Tableau is right, but I'd trust it more. There are numerous web postings about EXCEL's problems in computing statistics. I suggest you work out by hand one of your cases where EXCEL & Tableau differ and decide which one you want. The differences are typically from a different denominator ( /n or /(n1) ) or an interpolation formula)

9. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Ramon Martinez Jul 25, 2014 7:46 AM (in response to Ademola Okuneye)I was playing with your data in Excel, Tableau and Alteryx. I was able to get the same results in Alteryx using the Percentile function (it seems is the same implementation than Excel).
Definitively Tableau uses a method to compute Percentile that is efferent to the method used by Excel.
In Alteryx, we are able to select at least two methods to compute Percentiles: Percentile and PctNo0 providing different results.
Percentaile page in Wikipedia presents information about methods to compute Percentiles, including the implementation in Excel.
I've not fund the method used by Tableau so far.
Best
Ramon

10. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Jonathan Drummey Jul 25, 2014 9:42 AM (in response to Ramon Martinez)This falls into the category of one of those "Things that I learned that I've never had time to fully detail and write up." There are 4 areas where Tableau computes percentiles (PERCENTILE, WINDOW_PERCENTILE, RANK_PERCENTILE, and reference lines/bands/box plots). I've got an email somewhere with details on the algorithms, Tableau actually uses a couple of different algorithms in its functions so results of different functions aren't necessarily convertible, and don't necessarily match what we'd see coming out of Excel. In large samples (like 1K values or more) the results of the different functions will converge, but in smaller sample sizes they can be wildly different as you found.
Jonathan

11. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Jim Wahl Jul 28, 2014 8:08 AM (in response to Ademola Okuneye)WINDOW_PERCENTILE will get you the Excel style percentile if you disable aggregate measures. This last part is critical and probably not something most people realize they need to do with WINDOW_ functions based on measures.
Here's the formula:
Days P95 TC =
IF FIRST() == 0 THEN WINDOW_PERCENTILE(ATTR([Days]), .95) END
ATTR() is required because table calcs, such as WINDOW_XXX, require aggregates. ATTR() is an aggregation where if MIN(x) == MAX(x) you get x, else you get "*". IF FIRST() == 0 is used to return the value for just the first row of of the Days partition (the calc is the same for all rows and in a table you just want one value).
If you just put this calc in the view as I did below, you'll get NULL values because this view is at the category level of detail and there are multiple Days values for each category and, therefore, ATTR([Days]) is "*".
My next thought was to drag Days to the Detail button. Since days is a measure in your workbook, Tableau will add this as SUM(Days). This, of course, is not helpful, so you think you need to convert this a dimension. This gets you deceptively close (after adding, click the Days P95 TC field and change Compute Using to Days and then from the top menu bar select Analysis > Stack Marks > Off):
But it's not quite right. P95 for category B should be 177.9 and above it's calculated as 179.8. The problem is that by default Tableau aggregates measure values. Category B consists of 10 values: 30, 53, 55, 93, 114, 114, 145, 152, 157, 195. Since two of these values are the same, when you convert Days to a dimension, Tableau returns 9 values not 10.
You can see this by dragging Days on top of Days P95 TC (again, from the top menu select Analysis > Stack Marks > On).
To get the complete set of Days values, you need to deselect Aggregate Measures from the top Analysis menu:
Now you can drag Days P95 TC back to the view to get the correct WINDOWS_PERCENTILE() values that also mach the Excel algorithm for percentile:
TLDR  Tableau's Percentile vs Windows_Percentile 
For comparison here are your original values using the builtin percentile aggregation:
As others have said, there is no standard for percentile  R's percentile function has 9 methods (3 for discrete values, 6 for continuous), but I bet you could find another half dozen methods in the various R packages  even summary() is slightly different.
The Excel method (R Type 7) for your example, where you want the 95th percentile with 10 values is
the h value in the data for p95 = (101)*.95 + 1 = 9.55
Since h is a decimal, you use linear interpolation: take the 9th value + .55*(10th  9th) = 157 + .55*(195157) = 177.9.
The Tableau formula (appears) to use proportional interpolation: 157 + .95*(195157) = 193.1. (This is not one of the 9 R types, and doesn't really make sense to me, but it's hard to say it's wrong when there is no standard.)
Tableau Reference Lines Percentile
Tableau uses a third method for reference lines, which is equivalent to R type 2 for discontinuous values. Where the h value is Np + 1/2. In your example this is 10*.95 + 1/2 = 10, so the 95th percentile is also the max value of 195.
For group A, which has 26 values, h is 26*.95 + 1/2 = 25.2. Using this formula if the decimal is < .5 you round down. If it's > .5 you use the next value. If == 0.5, then you take the midpoint. For group A, you want the 25th value, which is 228.
One nice thing about this algorithm is that the percentile is usually a measure value (unless it's at the midpoint).
Jim
PS  I used Tableau 8.2 for your workbook. If you're on 8.1, you'll get an error, but you should be able to work through the above manually. Let me know.

P95 Analysis_jimw.twbx 51.1 K


12. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Ramon Martinez Jul 28, 2014 10:56 AM (in response to Jim Wahl)Wow!! Jim,
Thanks for this very informative post about Percentile Calculation in Tableau.
Best
Ramon

13. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
Matt Lutton Jul 28, 2014 11:25 AM (in response to Jim Wahl)Awesome! I got to the "deceptively close" result, but didn't realize aggregation was the problem. Thanks for the thorough explanation, as always, Jim!

14. Re: Percentile Calculation (P95) calculation in Tableau different from Excel
kettan Jul 28, 2014 12:22 PM (in response to Matt Lutton)1 of 1 people found this helpfulHere is a link to Jim's interesting explanation:
How to make WINDOW_PERCENTILE equal to reference line percentile?