I am using Tableau 8.2,I want to show calculations for current as well as previous year,how to apply this dynamically? it is getting possible if the year is written manually but it will be only temporary solution, how to do that dynamically? i.e on applying filter Year=2013 then sales and orders value of current-1 year should be displayed I have sales and orders On the Columns.
1
votes
Best way to do that is using a parameter. Then create a calculated field like YEAR(date) = Parameter - 1
– Inox
Thanks, but I need to include current year as well, I have calculated the current year by int(DATENAME('year',today() )), but the Gray area being is if my calculations are taking 2013 as the current year, then how are we supposed to calculate the current year for 2013 or any other year as the current year. I need some leads for the same. Thanks in advance.
– Karishma Dudhbade
Man, I understood nothing on this comment, try to edit the question with a better text. In the mean time, to filter in current year and last year, just YEAR(date) = Parameter - 1 OR YEAR(date) = Parameter.
– Inox
3 Answers
1
votes
0
votes
You can simply introduce two calculated fields which will give you the current and previous year. These can be used on the rows and columns shelves or any where else depending on whether your aiming for chart, text table or any other viz.
Calculated field 1 = Current Filter if datediff('year',[Date],TODAY() )=0 then 1 ELSE 0 END
Calculated field 2 = Previous Filter if datediff('year',[Date],TODAY() )=1 then 1 ELSE 0 END
The formulas above can be used if the required measure is just a count otherwise you could replace: then 1 with then [Amount] or whatever measure this applies to.