Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
What is Tableau?
3.
Sorting Data in Tableau
4.
Features of Sorting Data in Tableau
5.
Various Sorting Methods in Tableau
5.1.
Sorting by changing the Data Source Order
5.2.
Manual Sorting in Tableau
5.3.
Toolbar Sorting in Tableau
6.
Sorting Data using Parameters in Tableau
7.
Sorting Multiple Tables in Tableau
8.
Frequently Asked Questions
8.1.
What is Sorting in Tableau?
8.2.
What is the purpose of Parameters in Sorting Data in Tableau?
8.3.
Why are Calculated Fields the essential part of Sorting Data in Tableau?
9.
Conclusion
Last Updated: Mar 27, 2024
Easy

Sorting Data in Tableau

Crack Google SDE interview : Essential projects
Speaker
Saurav Prateek
SDE-2 @
20 Jun, 2024 @ 01:30 PM

Introduction

Hello Ninja, I hope you are doing great. Do you know how to Sort Data in Tableau? If not, don't worry. We are here to enrich your knowledge and clear all your doubts.
Sorting is required to present the data in a structured and meaningful way. It allows us to organize the data based on some criterias such as alphabetical order or custom defined logic. In this article, we will cover Sorting Data in Tableau in detail.
 

Sorting Data in Tableau


This article will discuss the topic of Sorting Data in Tableau. We will cover all its features and methods to sort the data in detail. We will also discuss the topics like Sorting Data using Parameters and Sorting Multiple Tables in Tableau. 

What is Tableau?

Tableau is a data visualization and business intelligence tool widely used by Data Analysts and professionals from various fields. It excels in quickly processing input data and providing meaningful visualization outputs. Tableau can connect to multiple data sources, including databases and cloud services, which allow us to combine data from numerous sources for detailed analysis. It offers a wide range of visualizations, including charts, tables, and maps, to represent the data meaningfully.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Sorting Data in Tableau

Sorting is arranging data within a visualization based on some criteria. Tableau offers several options to Sort the data within a Table in ascending or descending order. This makes ranking the items and finding the highest or lowest value from the data more accessible. It helps to eliminate irrelevant data from the large dataset. Tableau provides various optimized features such as Parameters and calculated fields which makes our task easier to sort the dataset having more than one Measure.The image below shows Sorting Data based on the “Sales” Measure.
 

Sorting Data based on Sales

Features of Sorting Data in Tableau

Tableau is a robust visualization tool that provides various features for Sorting Data. We can apply Sorting methods to various Dimensions or Measures to arrange the data in a specific order. Let’s discuss some features of Sorting Data in Tableau.

Features Description
Sorting in Ascending or Descending order We can sort the data in Ascending or Descending order based on the chosen field, such as Names, profits or Sales.
Sorting within Visualization Tableau allows us to Sort data within visualizations such as bar charts or graphs. We can sort the data points according to their values providing a clear representation to our data. 
Sorting Dimensions We can Sort the data based on Dimensions by alphabetically arranging the qualitative variables. This helps us to arrange our data in a logical sequence.
Sorting Measures We can sort the data based on Measures such as ‘sum’‘min’‘max’ or ‘avg’.  It helps us to find the smallest or largest value in our dataset.
Sorting by Hidden Fields Tableau allows us to Sort data based on the hidden fields that are not directly visible in the view. It is helpful in scenarios when we want to sort the data without displaying the field responsible for Sorting in the visualization.
Sorting within Groups We can create groups based on some criteria and sort the data within these groups. It enables us to compare data within different subsets of our subset.
Sorting based on calculated fields In Tableau, we can create calculated fields using some functions or formulae. We can Sort our data based on these calculated fields that tend to make our custom sorting logic. 

Various Sorting Methods in Tableau

Tableau provides various Sorting Methods that help us arrange data in a unique order. These Sorting Methods enhance data analysis and visualization in Tableau.

Let’s discuss these Methods one by one.

Sorting by changing the Data Source Order

This method allows us to sort the data based on the ascending or descending order of Dimensions.

In the example below, we have taken a ‘Customer Name’ Dimension and ‘Sales’ Measure. Let’s see the step by step process to apply this method.

  • Step 1: Here the ‘Customer Names’ are arranged in ascending order and our task is to change this default order to descending order. The image below shows the initial state of our graph.
     
image 2

 

  • Step 2: Select the dimension ‘Customer Name’ and go to the ‘Default Properties’. At last you have to choose the ‘sort’ property. The image below shows this step to select the ‘sort’ property.
     
image 2

 

  • Step 3: You must change the Data Source Order to descending order. The image shows this step of changing the Data Source Order.
     
Choose Descending Order

 

  • Step 4: Now you see the image below,  the “Customer Names” are arranged in descending order and our task is completed.
     
Descending Order of Customer Names

Manual Sorting in Tableau

It refers to rearranging the data within a visualization by dragging and dropping them to a desired position. 

Let’s see the step-by-step process to Sort the data in Tableau Manually.

  • Step 1: The image below shows the initial state of our visualization having the ‘Customer Name’ Dimension and ‘Sales’ Measure. 
     
Initial State of our table

 

  • Step 2: choose the Default Property ‘sort’ as ‘Manual’ instead of  ‘Data Source Order’. In the image below, we have highlighted the ‘Manual’ button.
     
Choose the Manual Sort Order

 

  • Step 3: Our next step is to drag and drop the ‘Customer Name’ whose position you must change. In the image below we have moved ‘Adam Bellavance’ to the top of the graph.
     
Drag and Drop the Customer Name

 

  • Step 4: The final image shows that ‘Adam Bellavance’ is at the top of the visualization. Our task is completed now, as we have changed the position of ‘Customer Name’ by dragging and dropping it.
     
final state of our table

Toolbar Sorting in Tableau

It refers to the functionalities provided by Tableau toolbar by which we can sort the data within a visualization. 

Let’s see how to sort the data using these toolbars.

  • The image below shows the toolbars provided by the Tableau. One is for Sorting the data based on the decreasing order of measure and the other is for Sorting the data based on the decreasing order of measure.
     
Toolbar Tools

 

  • The image below shows the visualization having sorted data based on the decreasing sales order.
     
Sort the data based on decreasing order of sales

 

  • The image below shows the visualization having sorted data based on the increasing Sales order.
     
sort the data based on ascending order of sales

Sorting Data using Parameters in Tableau

Parameters help sort the data dynamically. We create Parameters to define the Sorting criteria and link them to the calculated field. The calculated field is responsible for the Sorting behaviour based on the selected Parameter value. It is an optimized process that reduces the visualizations required. It enables users to explore the data from various perspectives.

Let’s discuss an example to understand the use of Parameters.

  • Step 1: We have taken a ‘Customer Name’ dimension and three measures including ‘Quantity’, ‘Profit’, and ‘Sales’. The image below shows this visualization. Our ultimate goal is to create a Parameter that will help to sort the based on these measures.
     
Initial State of our table

 

  • Step 2: Our next step is to create a Parameter. The image below shows how to create a Parameter.
     
click on create parameter

 

  • Step 3: Now give a name to a Parameter, and fill in all the measures we have taken. The image below shows all the details that need to be filled in.
     
create a parameter

 

  • Step 4: Now we must create a Calculated field to determine the Sorting behaviour based on the parameter value. 
     
click on create calculated field

 

  • Step 5:  The image below shows the statements which determine the Sorting behaviour based on different parameters. Here ‘MySortingParameter’ is the name of our Parameter. These if-else statements determine a Measure to be chosen for a particular Parameter value.
     
create calculated field

 

  • Step 6: choose a ‘Sort’ option for fixing the Sorting order.
     
choose a sort option

 

  • Step 7: Now our next step is to fill the “Field Name”, “Aggregation”, and “Sort Order”.  The image below shows all the values that need to be filled in these options.
     
fill the values in the sort property

 

  • Step 8: Now you can see, by fixing the Parameter value to “Quantity”, our data is sorted based on the descending order of the “Quantity”  field.
     
sorting based on Quantity field

 

  • Step 9: By assigning “Profit” to the Parameter value, our data will be Sorted based on the descending order of “Profit”.
     
sorting based on Profit field

Sorting Multiple Tables in Tableau

It refers to arranging rows within multiple Tables in a desired order. By Sorting Tables, we can compare data across Tables, leading to better data analysis.
Here we have taken an example where the ‘category’ dimension acts as the multiple Tables, and their ‘subcategories’ act as the rows for these Tables. We have taken three dimensions: ' Profit,’ ‘Sales,’ and ‘Quantity.’

Let’s see some steps to Sort Multiple Tables in Tableau.

  • Step 1: Create a Parameter and fill all the Measures in the list. We have given the name ‘SortBy’ to our Parameter.
     
create a parameter "SortBy"

 

  • Step 2: Our next step is to create a calculated field for determining the Sorting behaviour based on the Parameter. We have made a ‘Measure’ calculated list for our Parameter ‘SortBy.’
     
create calculated field for "SortBy"

 

  • Step 3: Create another Parameter for fixing the sorting order to descending or ascending. We have given the name ‘Sort’ to this Parameter. 
     
create a parameter "Sort"

 

  • Step 4: create a calculated field for the ‘Sort’ Parameter.
     
create calculated field for "Sort" parameter

 

  • Step 5: By fixing the ‘SortBy’ Parameter to ‘Sales’ and ‘Sort’ Parameter to ‘desc’, we have sorted our sub-categories based on the descending order of ‘Sales’.
     
sub-categories are sorted based on decreasing order of sales

 

  • Step 6: We are finally fixing the ‘SortBy’ Parameter to ‘Profit’ and the ‘Sort’ Parameter to ‘asc’. Now our data (sub-categories) is Sorted based on the ascending order of “Profit”.
     
sub-categories are sorted based on ascending order of profit

Frequently Asked Questions

What is Sorting in Tableau?

Sorting is arranging data within a visualization based on some criteria. Tableau offers several options to Sort the data within a Table in ascending or descending order.

What is the purpose of Parameters in Sorting Data in Tableau?

The Parameters define the Sorting Criteria such as ascending or descending order and are linked to the calculated fields. We can control the Sorting process without manual adjustments by changing these parameters.

Why are Calculated Fields the essential part of Sorting Data in Tableau?

The Calculated fields determine the Sorting behavior based on different Parameters. The statements written under the Calculated Fields determine the Measure chosen for a particular Parameter value.

Conclusion

In this blog, we’ve discussed Sorting Data in Tableau. We have covered all its features, various methods to sort the data in Tableau, Sorting using Parameters, and Sorting Multiple Tables in Tableau. 
We hope you enjoyed this article and gained some insights into this topic.
You can refer to Tableau Interview Questions and Tableau and Big Data to know more about Sorting Data in Tableau.
Head over to our practice platform Coding Ninjas Studio to practice top problems, attempt mock tests, read interview experiences and interview bundles, follow guided paths for placement preparations, and much more!!
Happy Learning Ninja!

Previous article
Making a Dual Axis Chart in Tableau
Next article
Introduction to Extract Filter
Live masterclass