Quick Table Calcs: How to Calculate Percent of Total in Tableau

by Emily Dowling

The quick table calculations in Tableau are really handy for doing fast analysis without having to do all the maths yourself.

Percent of Total is one of the quick table calculations and enables you to find the percent distribution of a measure, broken down by a dimension. For example, if you want to see Sales per Region, you could simply double click on Sales and Region, and Tableau will give you a breakdown of total (sum) sales for each Region.

Pic 1

You could also bring in another dimension to the view to give even more of a breakdown. For example, to see the sales per Region for each Product Category.

This is useful to see and compare total Sales in terms of value, but if you have a large disparity in Sales volumes across the Regions it may be more useful to see Sales in terms of percentage of total.

 

How to Calculate Percent of Total

If you were to calculate the percent of total manually, you would need to divide a sub amount by the total. E.g. to find out the percent of total sales that the Furniture category, in the Central region makes up, you would take the Sum of Sales for Furniture (£859,218) and divide it by the Total Sales for all categories in the Central region (£2,540,342).

Pic 2

However, Tableau will do all this for you in a few simple steps.

 

Step 1: Build your view

Drag Region and Product Category on to the Rows shelf and Sales on the Columns shelf, and you immediately have the value of Sales per Category per Region.

Pic 3

 

Step 2: Add a Table Calculation

Right click on the Sales pill and you will see a menu appear, navigate to ‘Quick table calculation’, where you will see a list of different table calculations. Next, click on Percent of total.

Pic 11

 

You’ll see that the x axis changes from the value of Sales in £, to the percentage of Total Sales.

 

Pic 5

 

However, you’ll notice that Tableau has automatically calculated the percentage of Sales for the whole view, i.e. as a percentage of all Sales across all Regions and Categories. In order to calculate the percent of total for each individual Region there is one final step to complete.

 

Step 3: Compute Using

Every table calculation has to be computed using something. Tableau will usually default to computing by ‘Table Down’ or ‘Table Across’ which can work in a lot of scenarios, but in this case it does not. Therefore, you need to right click again on the Sales pill, and now that you have added a Table Calculation you will see that the ‘Compute using’ option has appeared. If you want to compare one Categories sales to the other Categories’ sales, then you need to select compute using Product Category. Your totals will then update to show each Categories’ percent of sales compared to the other Categories’ sales for each Region.

Pic 12

 

You can always update this view to change the way the data is presented. For example, if you still want to show the Sales value in £ with your bars, you can put your Sales pill with the Table Calc (denoted by a triangle on the end of a pill) on to Tooltips or Labels and then bring in Sum(Sales) on to the Columns.

 

Pic 13

 

Another option, if you have a large number of Categories within each Region is to create a stacked bar chart. You can do this by simply dragging the Product Category pill from Rows and put it onto detail.

 

Pic 8

 

In order to compare the same Category more easily, you can instead drag Product Category on to Colour.

 

Pic 9

 

Finally, you can swap the x axis back to percent of total, to make the Categories slightly easier to directly compare. To do this, hold Ctrl (to duplicate the field) and drag your Sales pill with the Table calc (which was on detail) on to Columns and replace the SUM(Sales) that was there.

 

Pic 10