KNOWLEDGE BASE

Creating a "Percent Of Total" Calculated Field Without Using Table Calculations


Published: 05 Aug 2016
Last Modified Date: 05 Jul 2017

Question

How to create a view that shows the percent of total, without using table calculations.
For example: when using table calculations in views that contain grand or subtotals, the grand/subtotals may show unexpected results with a table calculation in use.

Environment

Tableau Desktop

Answer

Instead of table calculations, or using the TOTAL() function, use Level of Detail (LOD) expressions such as:
{ FIXED [<dimension(s) you are looking for the percentage of total information for>] : SUM([Measure]) } /
{ FIXED [<"Total" dimension(s)>] : SUM([Measure]) }

For example, using Superstore sample data, to show what percent of total each Segment is per Region:
  1. Select Analysis > Create Calculated Field. Name the calculation Percent of Total, enter the following calculation, and click OK: 
    { FIXED [Segment], [Region] : SUM([Sales]) }/{ FIXED [Region] : SUM([Sales]) }
  2. Right-click Percent of Total in the Measures pane and select Default Properties > Number Format... > Percentage
  3. Place Percent of Total on Columns
  4. Place Region on Rows
  5. Place Segment on Color.
  6. Place Percent of Total on Label.

 

Additional Information

To see these steps in action, watch the video below. 
Note: video is silent. 
Did this article resolve the issue?