Tableau Date and Time Functions
A free video tutorial from R-Tutorials Training
Data Science Education
4.4 instructor rating • 23 courses • 219,909 students
Learn more from the full courseForecasting and Time Series Analysis in Tableau
Use Tableau to work with time series, generate forecasts and even add R functionality to enhance Tableau.
03:54:35 of on-demand video • Updated December 2018
- visualize time series in Tableau
- perform calculations with time series data in Tableau e.g. SMA calculations
- use time series specific Tableau functions
- use the Tableau forecasting tools for exponential smoothing models
- understand the generated forecast models
- integrate R into Tableau in order to enhance forecasting capabilities
English [Auto] In this video we are going through the most common date functions in Tablo in the previous project. We already used to day and date part but Tablo has more to offer. So let's see what those functions are and how they work. Let's start with those that return dynamic data values they are today and now both of them work with empty parentheses. So there is no argument to specify. TODAY returns current date which is collected from your computer. If the date of your machine is not accurate today cannot return an accurate value either. It is the same thing with now. Now returns current day and current time but again it depends on the setting of your computer. Now let's take a look at those functions operating with date elements. There are three simple ones and the complex one the simple ones are day month and year. Each of them requires a one argument which has to be a date and this date can be hard coded. Like for example the 16th of September 2015 or it can be expressed by a date field or date parameter. Keep in mind that in most of the cases you can replace hard coded values with appropriate fields or parameters. This will make your calculations then namak and user friendly to keep things simple and understandable. We use static values to demonstrate what each function does but there is always the opportunity to make them dynamic. So let's use the 16th of September 2015 as our example to demonstrate the functions day month and year. Each of them returns an integer as a result of the calculation. So in this case day returns 16 month returns 9 year returns 2015. It's as simple as that. Don't forget that date and time need to be specified between hashes so blow recognizes them as date and time. Separate or between the parts is a hyphen a more complex form of this kind is the date part function which we already used in our previous project. You can think about date part as the combination of the functions Day Month and Year complemented with some further options. Date part consists of two required arguments and an optional one. The first required argument is the part which can be expressed by one of the following well use year which returns a four digit year quarter. If in integer between 1 and 4 month returns an integer between 1 and 12 day returns an integer between 1 and 66 which returns an integer between 1 and 7 and week gives an integer between 1 and 52. So as you can see that part always returns an integer. The second requires argument is the actual date you use. This can be expressed in proper date format or by a date field or a parameter. The third argument is optional and it is called start of week. You can specify the day the week should start with. For example if you use the weekday value for the date part argument that it matters whether the week should start on Sunday Monday or on any given day. If the argument is omitted the start of the week is determined by the data source. The next function is data name which is similar to date part but it returns a string instead of an integer. The arguments of the function are the same and thus date part date and start of week and the later is optional. If we take the following code with specified month and 30 first July 2011 the result would get just July if replaced month by year. We get 20 11. And the data type of The result is a string. Of course if you want to convert strings to date or time you can use the make date make time and make date time functions in case of make date you want to separate the date parts with commerce the order this year month and day. This will turn the input into date values the same procedure works for make time where you want to specify the hours at first then minutes and seconds again you can separate them with commas in case of make date time with specified date at first and then time date can be a string or an actual date but time must be date time. I think to know however is that make date time is available only for my sexual connections. Make a date and make time are applicable for other types of connections. These functions are really useful for concatenating date and time parts so you get fields of combined values as a result. At last let's see some functions for calculations with dates. The first one is date ed where you can specify a date and an interval and date. Ed adds the interval to the specified date part. Consequently the three arguments are date part into all and to date. So if he has a code like month 5 and the 18th of August 28 the result would be the 18th of January 2009. Since the expression Airds five month to the date specified the next one is date diff which returns the difference between two dates. The arguments are date parch date one date to and the always optional start of week. So if we specify day. First off October 2016 and first of November 2016 the way you would get is 31. Thus the difference between the two dates in day if we stayed month instead of day we would get one starter which can be an interesting argument. If we want the difference in weeks let's say I want to know how many weeks difference there is between the 6th of November and the 9th of November 2016 if I specify Sunday as start of week then I get zero. Whereas if I specify Monday for the same argument then the result is one. This is because in the first case both dates are in the same week since the sex was a Sunday in case of the second calculation. The week starts with Monday. So the dates are in different weeks the last functions are men and Max which can be used for numeric values as well as four dates in case of dates you want to keep in mind that they can choose minimum and maximum is only from two values or two feels. All right guys as you have seen date functions are somehow similar to one another. Regarding the syntax their functionalities are certainly different but the great thing is that once you have understood the syntax and the mechanics you will be able to use pretty much the whole plot.