KNOWLEDGE BASE

Comparing Year-to-Date Data Year-Over-Year


Published: 16 Sep 2014
Last Modified Date: 11 Aug 2016

Question

How to compare year-over-year data relative to current date.

Environment

Tableau Desktop

Answer

The below example uses Sample - Superstore data.
  1. Drag Order Date to Rows.
  2. Drag Sales to Columns.
  3. On the Marks card, change the chart type to Bar.
  4. On the toolbar, click the Abc button to show labels.
  5. Select Analysis > Create Calculate Field. Name the field such as [YTD Filter], and then enter the following formula:
    IF DATEPART('month',[Order Date]) < DATEPART('month',TODAY())
    OR
    (DATEPART('month',[Order Date]) = DATEPART('month',TODAY())
    AND  
    DATEPART('day',[Order Date]) <= DATEPART('day',TODAY())) 
    THEN "YTD"
    ELSE "Future"
    END
  6. Drag this calculated field to the Filters shelf.
  7. Select YTD, and then click OK.
Did this article resolve the issue?