Current Year and Last Year Measures Calculation in Tableau.
We can achieve this in several ways but according to Tableau KB below are the steps in 2 different ways:
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
Comments
Post a Comment