DATEDIFF Function in Tableau
DATEDIFF Function in Tableau

DATEDIFF Function in Tableau

2039

In recent years, advanced analytics has emerged as a critical component in modern business intelligence. Industry in all sectors are moving to take advantage of data science and data scientists need a platform they can depend on and business prefer to rely on tools that simplify their workflow giving best results.

Tableau, Which is one best data visualization and analytics tool, fits the bill perfectly. Let's see some integral features of Tableau which will help us build good visualization with our data. With the drag n drop feature. it is easy to define our requirement and make the analysis really fast. An example for this would be sales of a product. region wise on the Sample superstore dataset. With just a few drag drop fields one can create a visualization of product sales Region Wise. In Tableau we can easily compute, With help of Data Calculation, the average time it takes for an order to ship for each country. Get connected to the Dataset and Right click in the data pane and select Create Calculated Field. Lets call this "Time to Ship". We will use the function called DATADIFF to get the amount of time between Order Data and shipping DAte. The DATADIFF function needs to know what date part we want to consider. Note that the date part, in this case 'day', needs to be lowercase,in single quotes, and singular.We also have a comma. Next, bring out our start date, or Order DAte, another comma, and our end date, or Ship Date, and close parentheness.DATEDIFF('day'.[Order Date], [shipping Date]). We see this calculation is valid and we 'II click OK.

Let's colour the countries by using time to ship

We'II change the aggregation to Average.

We can edit the colors to a red-black diverging plaette and we'll reverse it because more time is bad.Now we can quickly see the countries that the longest times and we can focus on those areas.

Creating Tableau Dates

Tableau works very well with dates once it recognizes the data is a date. Sometimes in dataset, our dates arent in a comma format. We have our dates stored separately as Day, Month, and Yera. We want to create a calculated field that combines these fields into one that TAbleau can recognize.
Right click, create calculated field.name
this Tableau Date.

Right click, create calculated field.name
this Tableau Date.
In the calculation editro, We'll use the MAKEDATE function. The MAKEDATE function lets us combine separate fields into a date by. We simply need to bring in each piece in the riht order. We'll drag in Year, add a comma, then Month, a comma, then Day, and close parenttheness. The calculation is valid, and we'll click ok.
Now we have a date that Tableau can recognize.And we have all the drill down and functionality that we expect with dates.

 

Post Comments

Call Us