From the course: Tableau: Mastering Calculations
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
Calculating complex intervals between two points in time - Tableau Tutorial
From the course: Tableau: Mastering Calculations
Calculating complex intervals between two points in time
A few videos ago, when we discussed truncating dates, I promised you that we would write even more exciting calculations. So let's take a look at the following use case. I want to compare multiple quarters with each other according to their sales per calendar week. To do this, I need to calculate in which week of the relevant quarter a purchase was made. So I want to know the difference in weeks that have passed from the start of the quarter to the date of purchase. Let's create a calculated field and call it week number within quarter. We use the DATEDIFF function again. Our DATEPART in this case is week. And our start date is the first day of the quarter. This is why we start to nest functions. So let me break this function into several rows. That is not strictly necessary, but I like to do that because it gives my calculation more structure and makes it easier for myself and possibly for other colleagues to later understand what I've been doing here. Now we want to truncate the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
What does row-level mean?28s
-
Cropping and searching strings5m 34s
-
(Locked)
Splitting and replacing strings5m 42s
-
(Locked)
Concatenating strings1m 55s
-
(Locked)
Truncating date fields5m 10s
-
(Locked)
Calculating simple intervals between two points in time3m 7s
-
(Locked)
Calculating complex intervals between two points in time7m 38s
-
(Locked)
Challenge: Combine fields30s
-
(Locked)
Solution: Combine fields1m 26s
-
(Locked)
-
-
-
-
-
-