KNOWLEDGE BASE

## Calculating the Year Over Year Difference of the Percent Of Total

Published: 09 Mar 2016

### Question

How to obtain the year over year difference of the percent of total of a measure.

Tableau Desktop

### Option 1

Use the built-in Table Calculation by right-clicking on the desired measure and selecting Quick Table Calculation, and then selecting Year over Year Growth.
Selecting this option will automatically convert the measure and format it into a percentage.

### Option 2

Create two calculated fields to achieve the same result:
1. Select Analysis > Create calculated field
2. Name the calculated field "Percent Of Total"
3. Enter the following formula and click OK
`SUM([Sales]) / TOTAL(SUM([Sales]))`
4. Select Analysis > Create calculated field
5. Name the calculated field "Percent Difference"
6. Enter the following formula and click OK
`(ZN([Percent Of Total]) - LOOKUP(ZN([Percent Of Total]), -1)) / ABS(LOOKUP(ZN([Percent Of Total]), -1))`
7. Right-click the new measure "Percent Difference" and select Format, then format the field as a percentage.

To view the above steps in action, see the video below.
Note: the video has no sound.