Date calculations of Tableau:
The date calculation function on Tableau can be utilised for simplifying time-based calculations. This may include
· Adding a time interval (months, days, seconds etc..) to a set time/date,
· Calculating the set time interval between two time points
· Quoting the name of a time interval within a date
Adding a time interval (months, days, seconds etc..) to a set time/date:
Sometimes you may want to display a projected time period on Tableau. E.g. how long the delivery of a product would take. By using the DATEADD function, we can add a fixed time interval to a date field to work out the approximate time it took/will take for that product to arrive.
Notice, when writing the time interval, it must be in lowercase without plural (day not Days).
Calculating the set time interval between two time points:
Sometimes you may want to calculation the time between two timepoints. For example, how the delivery actually took. In this case, we would use the DATEDIFF function. This will calculate the difference in time between each timepoint in the specified time interval.
Quoting the name of a time interval within a date:
This may be useful when trying to only display the month of when the most deliveries occurred. For this, we use the DATENAME function. This will for example only display the month at which a order was placed.