### How to Calculate Percentile in Tableau

Tuesday, February 8th, 2022

Tableau has a Percentile function:

Percentile(expression, number)

And will return the percentile corresponding to number for the given expression. The Percentile function acts as an aggregate calculation because it takes a set of values as an input and returns a single value. In this case, Percentile takes a set of values and returns the specified percentile for those values.

It’s easier to understand with an example, of course!

This calculation will return the 75th percentile for the Exam Scores. Here it is in action:

- The 50th percentile for the exam score is 62… so about half the students scored higher and half scored lower.
- The 75th percentile is 81, so about a quarter of students scored higher.
- The 0th percentile would give the lowest score on the exam and the 100th percentile would give the highest score

We can add the Gender dimension to the view and see how the percentiles differ:

## The Percentile Table Calculation

The Percentile function returns the specified percentile for the underlying data at current level of detail in the view.

Tableau also has a percentile table calculation. This percentile is calculated based on the values in the visualization, rather than the underlying data in the visualization. Here’s what it looks like:

Notice that the data is aggregated with SUM(Exam Scores). The Percentile table calculation operates on the values * after *they have been aggregated in the view.

Here’s the test data and the workbook.

Hope this was helpful. Post a comment if you have any questions.