Creating Year To Date and Month To Date Calculations

Published: 11 Mar 2017
Last Modified Date: 30 May 2018


How to create and display Year to Date and Month to Date calculations. 


Tableau Desktop


Option 1

  1. Select Analysis Create Calculated Field 
  2. Name the field YTD Sales, enter the following calculation, then click OK: 
    IF [Order Date] <= TODAY() 
    AND DATEDIFF('year',[Order Date],Today())= 0 THEN [Sales] END
  3. In the Measures pane, right-click the YTD Sales calculation and select Duplicate
  4. Right-click YTD Sales (Copy), select Edit, and make the following changes, then click OK: 
    • Name the field MTD Sales 
    • Change 'year' to 'month'. 
  5. Drag YTD Sales to Columns
  6. Drag MTD Sales to the YTD Sales axis. When you see an icon with a double horizontal ruler, release the mouse button. 
    A screenshot of the double horizontal ruler
MTD Sales and YTD Sales will now display on the same axis. 
User-added image

Option 2

Sample data, such as Superstore, may not contain dates from this year. If there is no data from this year, the above calculations will display 0.
To replicate these instructions with sample data, substitute a parameter for TODAY(): 
Right-click in the Measures pane and select Create Parameter. Enter the following options, then click OK: 
  • Name: Today
  • Data Type: Date
  • Current Value: enter the most recent date in your data source
In the above calculations, substitute the parameter, Today,  for TODAY(). 

Additional Information

To view these steps in action, see the video below.
Note: the video has no sound. 
Did this article resolve the issue?