Post5

Dynamic Pie Charts in Tableau

Posted by Poliparthi Maheswararao

Tableau is arguably one of the most preferred data visualization tools in the Business Intelligence Industry. It converts raw data into easily understandable formats, enabling marketers, researchers, business owners, and other users to make informed decisions.

The visualizations created on Tableau are in the form of dashboards and worksheets and make use of data fetched from multiple sources and data warehouses. These visualizations can be anything from tables to charts. Out of the various types of charts available for visual representation of data, the pie chart is easily one of the most omnipresent chart types. It represents the size relationship between the parts and the entire thing, which makes it popular among users. The pie chart helps companies display their performance, including sales, profits, and other business metrics over the year, with the sum of the slices/divisions being the total sales or profit during the year.

Despite its usefulness, the pie chart is not the first choice chart type of many users. The argument is that pie charts are rarely a good fit for the problem they are intended to solve. However, while exploiting the functionality of the pie chart in Tableau, we came across several functionalities that normal users are not aware of. For instance, we created dynamic pie charts in Tableau that helped us get more information on the dashboard than we previously ever had.

This blog post answers the why’s and how’s of dynamic pie charts in Tableau.

Problem statement

We had huge volumes of sales data for our different products across the states. The need was to show this data, defined by states, in pie charts on a matrix. We needed to select the number of rows and columns, dynamically, and see all the data points in a single sheet for better understanding.

How we plan to achieve it

We are going to place all the ‘States’ in either column or row shelf to get all the states pie charts in a single row or column as detailed.

Placing ‘States’ in different rows

Placing ‘States’ in different columns

Solution

We can solve the problem using multiple calculated fields. Here’s how we get the result, step-by-step.

Step 1: Create a parameter with the name Number of Columns having the data type as an integer with values ranging from 1 to 15.

This is to provide a dynamic selection for the number of columns for the row/column matrix.

Step 2: Create a calculated field with the name index over the “State” dimension to rank all the states in ascending order.

RANK_DENSE(MIN([State]),’asc’)

Step 3: Create a calculation with the name column over the index field and Number of Columns parameter.

Column:

IIF(([index] % [Number of Columns])=0,[Number of Columns],[index] % [Number of Columns])

Create two more calculations with the name as RowVal and Row.

RowVal:

[index]/[Number of Columns]

Row:

if [RowVal]=int([RowVal]) then [RowVal]

elseif [RowVal]<0 then int([RowVal])

else int([RowVal]+1) end

The above calculations will enable us to place the ‘States’ in the row/column matrix. The column field will assign the column value and the Row field will assign the row value.

Step 5: Select the mark type as Pie, then use ‘Category’ in color shelf, ‘Sum (Sales)’ in angle shelf and place the ‘State’ in the details shelf.

Now place the column calculated field in columns shelf and Row field in rows shelf to get the following view.

Right-click the column filed, select the ‘edit table calculation’ and in the specific dimension section, select both the ‘Category’ and ‘State’ dimensions and do the same for the row field, and you will get the following view.

Now, right-click the Number of Columns parameter and select ‘show parameter control’ and hide the headers for columns and rows. This will give us multiple pie charts on a single sheet as below.

In the End

Pie charts in Tableau bring more to the table than meets the eye. Getting multiple pie charts in a matrix provides users a comprehensive view of the data, highlighting all the necessary information, which enables them to strategize, plan, and make informed decisions.

We believe you too would be able to create dynamic pie charts in Tableau following the steps and reap its benefits.

That’s all from our side. Let us know your experience and suggestions in the comments below.

Until next time!

Related Posts

  • Understanding Oracle Multitenant 12c database

    Overview of Oracle Multitenant Databases Overview Database 12c Enterprise Edition introduces Multitenant, a new design that empowers clients to effortlessly merge numerous databases, without changing their applications. This new design…

  • Tableau – Sets and Hierarchy functionalityTableau – Sets and Hierarchy functionality

    Business Intelligence and visual data analysis are core requirements of today’s businesses. While there are numerous tools with such capabilities, Tableau is among the most preferred BI tool for its…

  • Show/Hide Filter in TableauShow/Hide Filter in Tableau

    Despite the presence of several quick filters, legends, and other links, we may sometimes require more space to display data in the Tableau Dashboard. There’s, however, a restriction on the…

  • Removing Default ABC Placeholder in TableauRemoving Default ABC Placeholder in Tableau

    Tableau, a multipurpose tool gives users the freedom to exercise their creativity when developing visually rich reporting. Among its various liberties of building new views, altering the default formats of…

  • Formatting Individual Columns in Tableau (Dual-Axis Crosstabs)Formatting Individual Columns in Tableau (Dual-Axis Crosstabs)

    A simple step by step explanation with screenshots attached! Tableau can only format based off one value.  For example, you can have a chart that displays Sales and Profit, but…

  • Working with SQL Server Database on Microsoft Azure (Part 3)Working with SQL Server Database on Microsoft Azure (Part 3)

    This is the third and the final part of the series. We started with learning to register MS Azure and create SQL database & objects. Progressed to migrating the on-premise…

Leave a Reply

Your email address will not be published. Required fields are marked *