Returning Profit for Current and Previous Year Using a Parameter

Published: 27 Feb 2014
Last Modified Date: 20 Jan 2019


How to return the profit for current and previous year using a parameter to choose current year.


Tableau Desktop


Create the parameter:

  1. Right-click the Parameters pane and select Create Parameter....
  2. Name the paramter This Year.
  3. Under Data Type select Integer.
  4. Under Allowable Values select List.
  5. Enter 2010, 2011, 2012, and 2013 in the list of date values.
  6. In the Display Format drop-down menu, select Number(Custom).
  7. Clear the selection for Display thousands separator.
  8. Enter 0 for the number of decimal places.
  9. Click OK.
  10. Right-click This Year and select Show Parameter Control.

Create the calculated field:

  1. Go to Analysis > Create Calculated Field....
  2. Name the calculated field This Year Profit.
  3. In Formula enter IF YEAR([Order Date]) = [This Year] THEN [Profit] END.
  4. Repeat steps 1-3 with name Last Year Profit and formula IF YEAR([Order Date]) = [This Year] - 1 THEN [Profit] END.

Build the view:

  1. Drag Customer Segment to the Rows shelf.
  2. Drag This Year Profit to the Column Shelf.
  3. Drag Last Year Profit to the Column Shelf.
Did this article resolve the issue?