Converting Non-Date Time Dimensions in Tableau

Nikhil sharma
3 min readApr 5, 2022

Time functions are several of one of the most effective Tableau Tutorial features, nevertheless what happens any time you do have a time-based sizing that’s not within a standard time format? Recently I came across this challenge together with a client task. They had marketing campaign data aggregated upon a weekly schedule but grouped directly into periods of months. The particular overall schedule had been thirteen four-week durations kept in the dimension field known as “Period” similar in order to this example:

Method 1:- Using the LAST Function to show the last N weeks

Tableau calculations to the rescue! Whenever we have the Time period field in the view, we use the LAST functionality to create a filter and designate how many series away from the last value we want to show. This works great for a pattern chart that shows the last ten periods. We are able to also use an unbekannte here to effectively modify the number of rows to show.

To show the way the LAST functionality works, we create a calculated field that is merely LAST() and drag it onto the view outside the window together with the Time period field. We see the value came back for every single row is the fact that the row’s position is away from the last line, with a catalog starting at zero.

In the event we like to be able to show the previous 10 periods, most of us build a simple boolean filter calculation, and move it onto typically the filter shelf, together with select to indicate simply TRUE values. Most of us will use < 10 (of course not ≤) for the reason that the list starts at zero.

Method 2: Converting a dimension to a Date Format

Another challenge is presenting only the previous week’s data without the period aspect in the lovely view. Generally, there are a partner's ways to do this, but the most versatile is converting the period in to start a date format.

Since we certainly have the year, period, and week in the time dimension, we can write a few calculations to give us the week number of the season and then approximate a particular date. It need not be exact for the purposes.

An individual could nest your calculations as one, but I favor simplifying and using separate job areas. First, we need to grab the season from each period. This one is pretty straightforward, and we can use the LEFT performance to seize what we need considering that the year is at first each thread.

Upcoming, we need to extract the full week number. This your a little more complicated since it is dictated by the time and by the full week. Since the guitar strings are two extents (when the cycles are able to 10 and up), we can create a simple IN THE EVENT statement to examine the length, get back the period and week number, and then perform some math to analyze the best week variety of 12 months.

--

--