0
votes

How do I dynamically calculate the Year To Date (YTD) for the current year without using a table calculation in Tableau?

I have used the below formulas to calculate YoY for the current year:

if datediff('year',[Date],TODAY())=0 then [Sales]  END

For the previous year:

if datediff('year',[Date],TODAY())=1 then [Sales]  END

YoY:

sum(current year)/sum(previous year)-1
2
The question is for YTD not YoY. That was a mistake.My badkeerthana

2 Answers

0
votes

create a calculated field:

[date] >= MAKEDATE(Year(today()),1,1) and
[date]<= today()

Drag this to filter and select True

0
votes

It depends on what you're trying to achieve. If you want to filter dates to show only values in the current year without a table calculation, then you could create a calculated field like below and filter on the result:

if Year([Date]) =  YEAR(TODAY()) then "YTD" else "Not" END