Sort Your Data

Lesson Objectives

 After completing this unit, you'll be able to:  

  • Define and contrast computed sort and manual sort.
  • Use computed sorts and manual sorts to organize data in a view.

What Is Data Sorting?

Data sorting is any process that involves arranging data into some meaningful order to make it easier to understand, analyze, or visualize. When working with data, sorting is a common method used for visualizing data in a form that makes it easier to digest the story you want to tell with the data.

As you are analyzing your company’s sales data for furniture, you’re looking to answer this question: Which bookcase has the most sales?

Consider the example below. Comparison of data when sorted alphabetically vs sorted on Sales data. View A shows product names sorted on Sales. View B shows products sorted alphabetically.

View A tells you Riverside Palais Roy bookcase has the most sales. View B does not tell you that right away. That’s because view A is sorted by Sales, while the data in view B is sorted alphabetically. This example gives you an idea of why the right sorting of data is important to quickly ask questions of your data.

Tableau has multiple methods for sorting data in views, including computed sorts and manual sorts.

Computed Sort vs Manual Sort

Let’s start by understanding the difference between the two sorting methods available in Tableau. Check out the video to learn the difference between computed sort vs a manual sort.

Computed Sorts

A computed sort organizes the data in the view by applying rules, such as sorting alphabetically or sorting quantities in descending order. Computed sorts are dynamic. If the data changes, the view will update to keep the computed sort order. There are several ways to create a computed sort.

Sort Using One Click

If the field is in the view, a computed sort can be created using one click. 

  • Hover over an axis, and click the sorting icon when it appears. A view showing the sort icon on the axis (Sales)
  • Or, on the toolbar, click either the ascending or descending sorting icon. If you hover, a tooltip appears that describes how the sort will be performed (based on fields in the view and current view selections). Ascending and Descending sort icons on the toolbar

Sort Using the Sort Dialog 

You can create more complex computed sorts using the Sort dialog.

Sort dialog showing the Sort By and Field Name options

When sorted as shown in the above Sort dialog, the products are sorted on quantity. 

Sales by Region sorted by the sum of the Quantity of items sold by each region

Manual Sorts

A manual sort organizes the data in a fixed order, for example, to show a particular region's sales first. Manual sorts are an easy way to sort data quickly, but they are not dynamic. Manual sorts are maintained even when the data changes. For example, the sales for the manually sorted region will still be shown in the order specified, even if you add new regions.

Manual Sort Using Drag and Drop 

You can do a manual sort by dragging the selected headers or labels to reorder them.

A view showing how to change the order of a header or label using drag and drop

Manual Sort Using the Sort Dialog 

Manual sorts can also be created using the Sort dialog.

Sort dialog showing the up and down arrows to manually sort labels

You learned how to sort data in a view using computed and manual sorts. Now it’s your turn to sort the data in the views you have created for your company data. 

Sort Data

Your manager has additional questions on your view. She wants to know which products have the most sales within a category and which products are most profitable. In the past, products in the Technology category have had lower sales compared to other products. So, she is most interested in seeing data for that category of products.

Sort by Fields in a View

You have created a view that shows the sales for product subcategories, separated by category.

  1. Launch the Trailhead Simulator.
  2. Click Sort by Fields in a View.
  3. Click Begin.
  4. Right now, the categories and subcategories of products are sorted alphabetically, but you want to see them in a different order that you define manually, with Technology listed first, then Furniture, and then Office Supplies. In the view, drag the Technology header, and drop it above Furniture.
  5. Next, you want to order the subcategories from highest to lowest based on sales. On the Sales axis, click the Sort icon Sort icon. (You can toggle between an ascending and descending sort by clicking the Sort icon). You now have a view of all products sorted from highest to lowest sales within each category of the product based on sales. The view should look like the following: Products sorted from highest to lowest in each category based on sales
  6. Click Next Exercise to continue to the next exercise.

Sort by Fields Not in a View

You have a view that shows product categories and subcategories, with subcategories sorted by sales. Now you want to investigate how profitable the subcategories are by modifying the existing sort so that the view is sorted by profit. To make the view easier for your manager and coworkers to understand, you should also color encode the bars by profit.

  1. Make sure that you are in the Sort by Fields not in a View simulation, If you are not there yet, launch the Trailhead Simulator, and click Sort by Fields not in a View.
  2. Click Begin.
  3. On Rows, right-click Sub-Category, and then click Sort.
  4. In the Sort dialog box, under Sort by, leave the selection as Field and click the Field Name dropdown.
  5. Select Profit from the dropdown list.
  6. Leave the aggregation as Sum and close the Sort dialog. The view now shows items sorted by their profitability. Copiers is at the top of the list. Despite its lower sales, it is highly profitable. We can confirm this by bringing Profit to the view and showing it in color.
  7. From Measures, drag Profit to Color on the Marks card. Subcategories of products sorted by Profit
  8. Click Home to restart the activity or Exit to continue.

In this module, you learned how to use filters and the various sorting techniques in Tableau Desktop to narrow down and arrange the data to quickly find answers to your questions. You are now ready to share your findings with your manager and the rest of the team.

Resources

無料で学習を続けましょう!
続けるにはアカウントにサインアップしてください。
サインアップすると次のような機能が利用できるようになります。
  • 各自のキャリア目標に合わせてパーソナライズされたおすすめが表示される
  • ハンズオン Challenge やテストでスキルを練習できる
  • 進捗状況を追跡して上司と共有できる
  • メンターやキャリアチャンスと繋がることができる