Dates are one of the key fields which is extensively used in most of the data analysis scenarios. Hence, Tableau provides a large number of inbuilt functions involving dates. You can carry out simple date manipulations such as adding or subtracting days from a date. You can also create complex expressions involving dates.
Following are the steps to create a calculation field and use date functions in it.
While connected to Sample superstore, go to the Analysis menu and click ‘Create Calculated Field’, as shown in the following screenshot.
The above step opens a calculation editor, which lists all the functions available in Tableau. You can change the dropdown value and see only the functions related to Date.
Now, find out the sales volume along with the difference in the date of sales in months from 21st March 2009. For this, create the formula as shown in the following screenshot.
Now to see the created field in action, you can drag it to the Rows shelf and drag the Sales field to the Columns shelf. Also drag the ship Date with months. The following screenshot shows the Sales values.