How to Calculate Median in Tableau

Cody Schneider••6 min read

Calculating an average is easy, but it's often the wrong metric for understanding your business. A couple of mega-deals or an outlier product can skew your average sales figure, giving you a misleading sense of performance. The median, however, tells you the true middle-of-the-road value, providing a much more accurate picture. This article will walk you through how to calculate a median in Tableau, from the simple drag-and-drop method to more powerful calculations for deeper analysis.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Why Use Median Instead of Average?

Before jumping into the "how," let's quickly cover the "why." The average (or mean) is calculated by adding up all your values and dividing by the count of those values. The median is found by listing all your values in order and picking the one right in the middle.

Imagine you're a real estate agent and you've sold five houses in a neighborhood for the following prices:

  • $300,000
  • $325,000
  • $350,000
  • $375,000
  • $2,500,000 (a massive outlier)

The average home price is $770,000. If you told a potential buyer that the average price in the area is over three-quarters of a million dollars, you'd be technically correct but completely misleading. The vast majority of homes sold for much less.

The median home price is $350,000. This is the value that sits squarely in the middle of the list. It much more accurately represents what a "typical" house costs in that neighborhood.

In business analytics, medians are great for:

  • Sales Data: Understanding the typical purchase amount when you have a few huge enterprise clients and many smaller ones.
  • Website Traffic: Seeing the median time on page, ignoring the few users who left a tab open for three days.
  • Deal Velocity: Calculating the median number of days it takes to close a deal, so a few deals that were stalled for a year don't inflate your average.

Basically, whenever you suspect that outliers might be warping your perspective, a median is your best friend.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Method 1: The Simple Aggregation using MEDIAN()

The fastest way to find a median in Tableau is to use its built-in aggregation function. This is perfect when you need a quick, high-level summary statistic.

Let's use the Sample - Superstore dataset that comes with Tableau. Our goal is to find the median sale amount across all transactions.

  1. Drag Your Measure to the View: Open a new sheet and drag the Sales measure onto the Rows shelf. By default, Tableau will aggregate this as a sum, so you'll see a pill that says SUM(Sales).
  2. Change the Aggregation to Median: Now, just change the aggregation.

That's it! The pill will change to MEDIAN(Sales) and your view will update to show a single bar or a number representing the median sales value for every single transaction recorded in your dataset. You could drag the Category dimension to the Columns shelf, and Tableau would automatically calculate the median sale for each category.

When to use this method: Use the simple MEDIAN() aggregation when you need a straightforward summary. It's great for KPI dashboards, simple bar charts, or text tables where a single median value per category is all you need.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Method 2: Using a WINDOW_MEDIAN() Table Calculation

The first method is great, but it has limits. What if you want to perform a calculation on an already aggregated value? For example, what if you want to answer the question: "What is the median of our total sales per customer?"

If you use MEDIAN(Sales), Tableau will look at every single row-level sale and find the median. But we want to first sum up all sales for each customer, and then find the median of those totals.

This is a perfect job for a table calculation, specifically WINDOW_MEDIAN(). Table calculations operate on the data that is currently visualized on your screen (the "window" of data).

Step-by-Step Instructions

Let's build a view that shows the sum of sales for each customer, and then use a table calc to find the median of that list.

  1. Build the Initial View:
  2. Create the Calculated Field:
  3. Add the Calculation to the View: Now you can use this calculation to add a reference line to your chart.

You will now see a vertical line on your bar chart indicating the median customer sales total. This provides powerful context, showing you exactly how many customers perform above or below the "typical" median customer.

When to use this method: Use WINDOW_MEDIAN() when you need to calculate the median of values that are already aggregated in your view. It's ideal for adding reference lines or performing calculations that depend on the entire set of marks displayed in your chart or table.

MEDIAN() vs. WINDOW_MEDIAN(): Which One Do I Use?

It can be tricky to know which function to choose. Here's a simple breakdown:

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Use the quick MEDIAN() aggregation when:

  • You want the median of the underlying, row-level data.
  • You are asking: "What's the median transaction size?" or "What's the median profit per item?"
  • Your analysis is simple, and you just need a summary metric for a chart axis or a KPI card. For example, a bar chart with a single median value for three regions.

Use the WINDOW_MEDIAN() table calculation when:

  • You want the median of an already aggregated set of values in your view.
  • You are asking: "What's the median of our total sales per state?" or "What's the median of our average discount per product category?"
  • You want to display the median alongside more granular marks, such as adding a reference line that shows the median across all bars in your chart.

The key difference is the stage at which the median is calculated. The regular MEDIAN() function works on an un-aggregated measure from your data source. WINDOW_MEDIAN() works on the measure after it's been aggregated based on the dimensions in your view.

Final Thoughts

Understanding when to use a median instead of an average is a crucial step toward more accurate data analysis, and Tableau provides the tools you need to calculate it correctly. For simple summaries of raw data, a quick aggregation change to MEDIAN() does the job. For more complex scenarios, like finding the median of already-aggregated values, the WINDOW_MEDIAN() function offers the flexibility you need.

While mastering these functions in Tableau is incredibly powerful, we know that sometimes you don't have time to build complex calculations - you just need a fast answer. That's why we built Graphed. We make it easy to connect all your marketing and sales data sources, then simply ask questions in plain English, like "what's the median deal size by sales rep this quarter?" to instantly generate real-time reports and dashboards without touching a single formula.

Related Articles