KNOWLEDGE BASE

Creating YTD and MTD Calculations


Product(s): Tableau Desktop
Version(s): 8.1, 8.0, 7.0
Last Modified Date: 16 Aug 2016

Article Note: This article is no longer actively maintained by Tableau. We continue to make it available because the information is still valuable, but some steps may vary due to product changes.


In Tableau, the relative date filter enables flexible analysis of time periods. Sometimes, however, you might want to see both year-to-date (YTD) and month-to-date (MTD) values for a particular measure on the same view. To accomplish this task, you can create date calculations.

Create calculated fields for YTD and MTD sales

Step 1

Select Analysis > Create Calculated Field.

Step 2

In the Calculated Field dialog box, complete the following steps.

  1. For Name, type YTD Sales.
  2. In the Formula box, build the following formula:

    IF [Order Date] <= TODAY()
    AND DATEDIFF('year',[Order Date],Today())= 0 THEN [Sales] END

  3. Confirm that the status message indicates that the formula is valid, and then click OK.

Step 3

In the Measures pane, right-click the YTD Sales calculation, and then select Duplicate.

Step 4

Right-click the new copy of the field, select Edit, and make the following changes to the calculation:

  1. For Name, type MTD Sales.
  2. In the Formula box, change instances of year to month.

  3. Confirm that the status message indicates that the formula is valid, and then click OK.

Step 5

From the Measures pane, drag YTD Sales to the Columns shelf.

Step 6

From the Measures pane, drag MTD Sales to the YTD Sales axis, and when you see an icon with a double horizontal ruler, release the mouse button.

This shows the two measures on the same axis:

 

Alternate Search Terms:year-to-date, month-to-date, calculation,
Did this article resolve the issue?