Show Previous Year Sales When Filtering Down To A Single Year

Published: 21 Nov 2017
Last Modified Date: 31 Dec 2019


How to calculate and show previous year sales when filtering down to a single year.


Tableau Desktop


DCreate two calculations:
Previous Year Sales 
LOOKUP(SUM([Sales]),-1 ) 


str(LOOKUP(max(DATEPART('year', [Order Date])),0)) 

Note: It is not necessary to wrap the !DateFilter calculation in a string, but it removes the commas and makes it look more like a date. 

By Using the !DateFilter on the filters shelf (make sure to change to Discrete), you can filter the view down to just a single year, and have our Previous Year Sales as a measure value underneath our regular Sales. 

See the example workbook for how to use these calculations .
Did this article resolve the issue?