0
0
Tableaubi_tool~10 mins

Date calculations (DATEDIFF, DATEADD) in Tableau - Cell-by-Cell Formula Trace

Choose your learning style9 modes available
Sample Data

This data shows order dates and corresponding ship dates for three orders.

CellValue
A1Order Date
A22024-01-01
A32024-01-15
A42024-02-01
B1Ship Date
B22024-01-05
B32024-01-20
B42024-02-10
Formula Trace
DATEDIFF('day', [Order Date], [Ship Date]) + DATEADD('day', 5, [Order Date])
Step 1: DATEDIFF('day', '2024-01-01', '2024-01-05')
Step 2: DATEADD('day', 5, '2024-01-01')
Step 3: 4 + '2024-01-06'
Cell Reference Map
     A           B
1  Order Date  Ship Date
2  2024-01-01  2024-01-05
3  2024-01-15  2024-01-20
4  2024-02-01  2024-02-10

Formula references A2 and B2 for the first row calculation.
The formula uses Order Date (A2) and Ship Date (B2) to calculate the difference and add days.
Result
     A           B           C
1  Order Date  Ship Date   Result
2  2024-01-01  2024-01-05  Error
3  2024-01-15  2024-01-20  
4  2024-02-01  2024-02-10  

Column C shows the formula result for row 2, which is an error due to type mismatch.
The result column shows an error because the formula tries to add a number to a date, which is not allowed.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does DATEDIFF('day', '2024-01-01', '2024-01-05') return?
A5
B6
C4
D1
Key Result
DATEDIFF calculates the difference between two dates as a number; DATEADD shifts a date by a number of units; adding them directly causes a type error.