KNOWLEDGE BASE

Calculating a Rolling 12-Month Value with DATEDIFF()


Published: 16 Sep 2014
Last Modified Date: 17 Oct 2017

Question

How to create a calculated field for a rolling 12-month period of a value using DATEDIFF.

Environment

Tableau Desktop

Answer

The following example is based on the Superstore sample data source.
  1. Go to Analysis > Create Calculated Field.
  2. Enter the following calculation: IF (DATEDIFF('month',[Order Date],TODAY()))<=12 THEN [Sales] ELSE null END
  3. Enter desired name for the field.
  4. Click OK.
Did this article resolve the issue?