
Explanation:
There are different ways to create a table calculation that shows sales growth over each year, but one possible answer is:
SUM([Sales])
LOOKUP(SUM([Sales]), -1)
PREVIOUS_VALUE(0)
To calculate the sales growth over each year, you need to compare the current year's sales with the previous year's sales and divide the difference by the previous year's sales. You can use the SUM, LOOKUP, and PREVIOUS_VALUE functions to achieve this. The SUM function returns the total sales for each year. The LOOKUP function returns the value of an expression in a target row, specified as a relative offset from the current row. The PREVIOUS_VALUE function returns the value of the expression in the previous row, or a specified value if there is no previous row. The formula for the table calculation is:
(SUM([Sales]) - LOOKUP(SUM([Sales]), -1)) / PREVIOUS_VALUE(0)
This formula subtracts the sales of the previous year (LOOKUP(SUM([Sales]), -1)) from the sales of the current year (SUM([Sales])) and divides the result by the sales of the previous year. If there is no previous year, the formula uses 0 as the denominator (PREVIOUS_VALUE(0)) to avoid division by zero errors.
References:
Tableau Certified Data Analyst Exam Prep Guide, page 11, section "Creating Calculated Fields" Tableau Help: SUM Function Tableau Help: LOOKUP Function Tableau Help: PREVIOUS_VALUE Function