What is Nested Sort in Tableau?

Cody Schneider7 min read

Building a chart in Tableau is one thing, but making it instantly readable is another. Nested sorting is a simple technique that organizes your data to tell a clearer story, helping you find top performers within specific categories instead of just an overall ranked list. This guide will walk you through what nested sorting is, why it’s useful, and exactly how to implement it in your Tableau dashboards.

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

What is Standard Sorting in Tableau?

Before diving into nested sorting, let's quickly touch on how standard sorting works. When you have a chart with multiple categories, like Categories and Sub-Categories of products, a standard sort organizes a dimension based on a measure across the entire view. For example, if you sort your Sub-Categories by Sales in descending order, Tableau will rank all sub-categories from highest to lowest sales, regardless of which primary Category they belong to.

Here’s what that looks like in practice:

Imagine you have a bar chart showing Sales by Category and Sub-Category. If you apply a standard sort on Sales, you'll see a chart where "Phones" (from the Technology category) might be at the top, followed by "Chairs" (from Furniture), and then "Storage" (from Furniture). The Sub-Categories are sorted correctly based on total sales, but their grouping under their parent "Category" becomes jumbled and hard to interpret. This global high-to-low ranking breaks the hierarchical relationship between your dimensions, making the visualization confusing.

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.

So, What is a Nested Sort?

Nested sorting, also known as contextual sorting, solves this problem. It allows you to sort a dimension <em>within the context of another dimension</em>. Instead of creating one giant ranked list, it creates a separate ranked list for each "pane" or "header" in your view.

Using our previous example, a nested sort would do the following:

  • Look at the "Furniture" category and sort its Sub-Categories (Chairs, Tables, Bookcases, Furnishings) by sales from highest to lowest.
  • Then, it looks at the "Office Supplies" category and independently sorts its Sub-Categories (Storage, Binders, Appliances) by sales from highest to lowest.
  • Finally, it does the same for the "Technology" category, sorting Phones, Accessories, Machines, and Copiers within that group.

The result is a clean, organized, and much more intuitive chart. You can easily see the top-performing Sub-Category <em>for each Category</em>, without losing the valuable structure of your data. This helps you answer more specific business questions, like "What is our best-selling product in the Technology division?" or "Which state is generating the most profit within the West region?"

How to Create a Nested Sort in Tableau: Step-by-Step

The best way to get a feel for nested sorting is to build one yourself. We will use the Sample – Superstore dataset that comes packaged with Tableau for this walkthrough.

Goal: Create a bar chart showing the highest-selling Sub-Categories for each product Category.

Step 1: Set Up Your Basic View

First, let’s build the initial chart. This is the foundation we will apply our nested sort on top of.

  1. Open a new or existing workbook in Tableau and connect to the Sample - Superstore data source.
  2. Drag the Category dimension to the Rows shelf.
  3. Next, drag the Sub-Category dimension to the Rows shelf, to the right of Category. This creates the hierarchy.
  4. Finally, drag the Sales measure to the Columns shelf.

You should now have a horizontal bar chart. Tableau automatically sorts the categories and sub-categories alphabetically. While the data is there, it’s not organized for insightful 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

Step 2: Use Tableau's Built-in Nested Sort Option (The Fast Way)

In recent versions of Tableau, creating a nested sort has become much easier with a dedicated option in the sort menu. This is the quickest and most common method today.

  1. Right-click the Sub-Category pill on the Rows shelf.
  2. Select Sort from the context menu. This will open the Sort dialogue box.
  3. In the Sort dialogue box, configure the following settings:
  4. Close the dialogue box.

That's it! Your chart is now perfectly nested. You’ll see that within the "Furniture" category, "Chairs" is now at the top. Within "Office Supplies," "Storage" leads, and for "Technology," "Phones" is the clear winner. The sort order for sub-categories is now specific to each category.

The "Classic" Method: Using a Combined Field

Before the "Nested" sort option was available, the community standard was to use a combined field. This method is still extremely useful to know, as it helps you understand the logic behind what Tableau is doing and can be used in more complex sorting scenarios where the built-in option might fall short.

Let's start from a freshly built chart (or undo the previous sort) and follow these steps.

Step A: Create the Combined Field

  1. In the Data pane (on the left side of your screen), find Category and Sub-Category.
  2. Select both fields by holding down the Ctrl key (or Command on a Mac) and clicking on each one.
  3. Right-click on either of the highlighted fields and go to CreateCombined Field....
  4. You can leave the default name, which will be something like "Category & Sub-Category (Combined)," and click OK. This new field now appears in your Dimensions list.

Step B: Add the Combined Field to Your View and Sort It

This combined field will serve as our sorting mechanism, acting behind the scenes.

  1. Drag your newly created Category & Sub-Category (Combined) field from the Data pane onto the Rows shelf. Place it to the far left, before the Category pill.
  2. Right-click this new "Category & Sub-Category (Combined)" pill on the Rows shelf and select Sort.
  3. In the Sort dialogue box, configure the following:
  4. Close the dialogue box.

Your bars are now sorted as intended. There's just one problem: you have a redundant, somewhat messy-looking header in your chart from the combined field (e.g., "Technology, Phones").

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.

Step C: Hide the Combined Field Header

This final step is simple but crucial for a clean visualization.

  1. Right-click the Category & Sub-Category (Combined) pill (the one you placed on the Rows shelf).
  2. Uncheck the option that says Show Header.

The header disappears, but the nested sort remains! You now have a perfectly polished chart that clearly visualizes top performers within each category.

When Should You Use Nested Sorting?

Nested sorting is more than just a formatting trick, it's a powerful analytical tool. Here are a few common scenarios where it can provide immediate value:

  • Geographical Analysis: Identify the top-selling cities within each state, or the top states within each region.
  • Product Performance: Find the best (or worst) performing products or services within each product line or business unit.
  • Sales Team Monitoring: Rank sales representatives by revenue or quantity sold within their respective sales territories.
  • Time-Based Analysis: Sort the days of the week by website traffic for each month, helping identify monthly patterns that might get lost in a global sort.
  • Comparative Analysis: Use it in stacked bar charts to order segments within each bar, making it easier to compare the contribution of the largest component across different bars.

Final Thoughts

Mastering nested sort in Tableau empowers you to move beyond basic, one-dimensional analysis and tell a more nuanced story with your data. By ordering dimensions within the context of others, you can create reports that are not only cleaner and more professional but also deliver clearer, more actionable insights without forcing your audience to do the mental gymnastics.

While techniques like nested sorting give you powerful control inside tools like Tableau, we know that getting to the final chart often involves a dozen clicks, confusing dialogue boxes, and a bit of trial and error. That’s where we've aimed to simplify the whole process. With Graphed, you can connect your data sources and create these kinds of insightful charts by just asking questions in plain English. Instead of building dimensions and configuring sort menus, you can just ask, "Show me my top 5 selling sub-categories for each category," and let the platform build the live, interactive visualization for you in seconds.

Related Articles