KNOWLEDGE BASE

Comparing Prior Year Data by Month


Published: 17 Sep 2013
Last Modified Date: 28 Dec 2017

Question

How to create a monthly year-to-date comparison filterable by calendar month.

Environment

Tableau Desktop

Answer

The following instructions can be reviewed in the workbook attached below.
  1. Open Tableau Desktop and select Analysis > Create Calculated Field to create a calculated field.
  2. In the Calculated Field dialog box, enter a name for the field. In this example, the field is named "Prior Sales".
  3. In the formula field, create a calculated field similar to the following and click OK:
    lookup(SUM([Sales]),-1)
  4. Drag Order Date to the Rows shelf, and then click the plus sign (+) on the YEAR(Order Date) field to expand to QUARTER(Order Date).
  5. Right-click on QUARTER(Order Date) and select Month.
  6. Double-click Sales and Prior Sales in Measures to add them to the view.
  7. Right-click on Prior Sales on Measure Values, and select Edit Table Calculation.
  8. Under Compute using, select Specific Dimensions.
  9. Check the boxes next to Month of Order Date and Year of Order Date. Click OK.
  10. From the At the level drop-down menu, select Year of Order Date.
  11. From Restarting every drop-down menu, select Month of Order Date, and then click OK.
  12. Right-click MONTH(Order Date) on Rows and select Show Filter.
Did this article resolve the issue?