Bits of Tableau
Sort Charts Like a Pro in Tableau Dashboards
An Easy Way to Sort Visualizations Based on Multiple Measures using Parameters
In this article, I want to share a useful tip that can give business users the flexibility to do custom sorting through a Tableau dashboard.
By the end of this read, you’ll be able to make a visualization where you can set the Top N instances, order the values by ascending or descending, and sort the values by multiple measures, as illustrated below.
Let’s get started with the tutorial then!
The dataset used is Tableau’s Superstore dataset and the objective is to visualize Superstore’s Top Performing States based on 4 measures: Count of Orders, Quantity, Sales, and Profit Ratio.
- Drag the needed Measures to Columns and Dimensions to Rows.
2. Create a String Parameter to Order Values By Ascending or Descending Order.
3. Create a String Parameter to Sort Values By the Measures.
4. Show the Parameters in the Visualization.
5. Create a @sort-by Calculation to Define the Parameters (Make Them Work) — I like to use ‘@’ to differentiate parameter defining calculations apart from other calculations.
6. Right-Click — Sort the Dimensions (State & Regional Manager) and Sort By @sort-by Calculation.
7. Sorted Results: Dimensions have been sorted based on the Order Values By and Sort Values By Parameters.
Yay! We have successfully created a custom sorting based on the multiple measures! Now, we want to add a Top N Filter to only display Top N instances in the visualization as a cherry on top.
8. Create an Integer Parameter to Set Top N Filter.
9. Create a @top-filter Calculation using the INDEX() function to Define the Set Top N Filter.
10. Drag the @top-filter to the Filter Shelf and Set it to ‘True’ so that only values fulfilling the calculation will be displayed.
11. Design the Dashboard and Display all the Parameters.
Congratulations! You now can sort the visualization based on the Count of Orders, Quantity, Sales, and Profit Ratio in Ascending or Descending order, as well as setting the Top N instances in the view.
For any inquiries, I can be contacted via LinkedIn. Hope this article can help you to make more impactful data-driven decisions by applying custom sorting parameters in your visualizations :).