What is Nested Sort in Tableau?
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.
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.
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.
- Open a new or existing workbook in Tableau and connect to the Sample - Superstore data source.
- Drag the Category dimension to the Rows shelf.
- Next, drag the Sub-Category dimension to the Rows shelf, to the right of Category. This creates the hierarchy.
- 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.
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.
- Right-click the Sub-Category pill on the Rows shelf.
- Select Sort from the context menu. This will open the Sort dialogue box.
- In the Sort dialogue box, configure the following settings:
- 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
- In the Data pane (on the left side of your screen), find Category and Sub-Category.
- Select both fields by holding down the Ctrl key (or Command on a Mac) and clicking on each one.
- Right-click on either of the highlighted fields and go to Create → Combined Field....
- 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.
- 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.
- Right-click this new "Category & Sub-Category (Combined)" pill on the Rows shelf and select Sort.
- In the Sort dialogue box, configure the following:
- 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").
Step C: Hide the Combined Field Header
This final step is simple but crucial for a clean visualization.
- Right-click the Category & Sub-Category (Combined) pill (the one you placed on the Rows shelf).
- 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
How to Connect Facebook to Google Data Studio: The Complete Guide for 2026
Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.
Appsflyer vs Mixpanel: Complete 2026 Comparison Guide
The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?