KNOWLEDGE BASE

Showing Measure Value For Current Year And Last Year Under Current Year Header


Published: 02 Jul 2020
Last Modified Date: 02 Jul 2020

Question

Showing measure value for current year and last year under current year header. Example: Showing sales for current year (2020) and last year (2019) under current year (2020) header

Environment

  • Tableau Desktop

Answer

Option 1:

1. Drag Year(Order Date) to Columns

2. Create a Calculation that returns sales for this year called Current year sales:

    if YEAR([Order Date])=YEAR(TODAY()) then [Sales] end

3. Create a Calculation that returns sales for last year called Last year sales:

   IF YEAR([Order Date])=YEAR( TODAY())-1 then ([Sales]) end

4. Create a look up calculation called look up if current year with following formula:

   IF ATTR(YEAR([Order Date])=YEAR(TODAY())) then
   LOOKUP(SUM([Sales]),-1) end

5. Drag look up if current year to filters and select Special -> Non-null values

6. Hide field labels for columns

Option 2:

1. Create a Calculation that returns sales for this year called Current year sales:

    if YEAR([Order Date])=YEAR(TODAY()) then [Sales] end

2. Create a Calculation that returns sales for last year called Last year sales:

   IF YEAR([Order Date])=YEAR( TODAY())-1 then ([Sales]) end

3. Create a calculation called Current year:

   YEAR(TODAY())

4. Drag Current year to Columns and make it a dimension

5. Hide field labels for columns

 
Did this article resolve the issue?