A Difference calculation helps compute the difference in values from a previous, next, first, or last data marks across a table. It defaults to compute the difference between previous values.
Using Tableau’s Global Superstore Orders table:
- Drag an Order Date field from the Data pane to the Columns shelf.
- 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), select Quick Table Calculation and Difference. This second Sales field will have a delta symbol.
- Control and drag the SUM(Sales) field to the right of the Rows shelf four times.
- Right-click the second SUM(Sales) field and select Relative to, and Previous
- Right-click the third SUM(Sales) field and select Relative to, and Next
- Right-click the fourth SUM(Sales) field and select Relative to, and First
- Right-click the firth SUM(Sales) field and select Relative to, and Last
- Drag an Order Date field from the Data pane to Label on the Marks card.
Format: You could format the fields with corresponding currencies.
Relative to Previous: Subtracts a value from a previous one (next to it). $2,677K minus $2,259K = $418K. $3,406K minus $2,677K = $728K. $4,300K minus $3,406K = $894K.
Relative to Next: Subtracts a value from the next one (next to it). $2,259K minus $2,677K= ($418K). $2,677K minus $3,406K = ($728K). $3,406K minus $4,300K = ($894K).
Relative to First: Subtracts every value from the first one. $2,2677K minus $2,2677K = $0K. $2,677K minus $2,259K= $418K. $3,406K minus first one $2,259K = $1,146K. $4,300K minus first one $2,259K = $2,040K
Relative to Last: Subtracts every value from the last one. $2,259K minus $4,300K = ($2,040K). $2,677K minus $4,300K = ($1,622K). $3,406K minus $4,300K = ($894K). $4,300K minus $4,300K = $0K