Year To Date Total (YTD) calculation helps compute how a value increases year to date. For example, it helps compute increases in sales over time (quarter by quarter within a year). It is similar to the running-total calculation but requires two date elements and a measure.
Using Tableau’s Global Superstore Orders table:
- Drag an Order Date field from the Data pane to the Columns shelf. Default is Years.
- Drag an Order Date field from the Data pane to the Columns shelf. Change it to Quarters.
- Drag a Sales field from the Data pane to the Rows shelf.
- Drag another Sales field from the Data pane to the Rows shelf.
- Right-click this Sales field (second one), Quick Table Calculation, and select YTD Total. This second field will have a delta symbol.
- Drag a Sales field from the Data pane to Label on the Marks card.
Format: You could format the two Sales fields with corresponding currencies.
Relative to Order Date: The default here is to compute using the Order Date field.
Final Result: I have created two graphics (top and bottom) to show the difference between regular sales over time and year to date sales. For example, in Year 2012, Sales increased ($336K + $479K) = $814.65K or $815K between Quarter 1 and Quarter 2. Then from Q2 to Q3 adding $814.65K + $613K = $1,427.96K. Lastly, from Q3 to Q4, adding $1,427.96K + $831K = $2,259.45K or $2,258.96K. Next year, the quarters are added again.