How to Compare Quarters on One Complete Timeline in Tableau


How to Compare Quarters on One Complete Timeline in Tableau

by Elliott Stam

I was working with a client recently, and they asked me a seemingly simple question: “How do you compare quarterly performance across a single time frame in Tableau?”

They were looking for this:

Quarterly analysis in Tableau

My first thought was that this is very straightforward – all you should need to do is drag the performance metric to Rows, the time field to Columns and a copy of that same time field to Color on the Marks card. From here, we can create the view below:

Metric > Rows, Time > Columns, Time > Color” src=”/wp-content/uploads/sites/default/files/blog-content/QA2.png” /></p>
<p>But this wasn’t what we wanted. We were looking for a comparison of specific quarters in their entirety, over a time period of ninety days, not thirty. Easy fix, right? Just drag another copy of the <strong>Date</strong> field to <strong>Columns</strong>:</p>
<p align=Drag another copy of date to columns

Not quite what we’re looking for.

Making Tableau Show the Full Quarter

Now let’s dive into how you can make Tableau show the entire 90-day spectrum (instead of just the Day date part we see now), all inside the same view, while displaying each quarter in its respective line and color. This will require a few calculations:

Quarter (n-1) calculation in Tableau

The calculation above is designed to search for dates that happened during the previous quarter when compared to the quarter we have selected as our Quarter Parameter. If you need to compare the selected quarter to other quarters in addition to the previous quarter defined above, then you will create more calculated fields like this one, adjusting the numerical values appropriately.

If you’re wondering what exactly that Quarter Parameter does, it simply creates a drop-down list of all the quarters we could use as our current frame of reference. Tableau will anchor the calculations around the time period I select within the parameter. See the two images below for a look at how to create the parameter.

(Hint: To easily generate a quarter parameter, first create a calculated field that outputs the DATETRUNC quarter values for your date field.)

Quarter DATETRUNC calculation in Tableau

Now you can right-click on this Quarter field in the Data pane and create the parameter directly from the values it holds, thus outputting a list of the quarters present in your data:

Edit Parameter

The contents of the parameter shown above were generated directly from the Quarter calculated field that was just explained.

It’s always a good idea to double check that our formulas are outputting sane results. The view below serves the purpose of verifying that the Quarter (n-1) calculated field is shifting dates forward by one entire quarter. In the table, we can see that the Day of Quarter (n) column displays unaltered date values while Quarter (n-1) shifts its date values forward in time by exactly one quarter (dates in December 2012 become dates in March 2013). If we were to scroll through the table, we would find that Quarter (n-2) shifts its date values forward by exactly two quarters, and Quarter (n-4) shifts its date values forward in time by exactly four quarters:

Quarter days table

Now we need to create a calculated field to store each quarter’s sales. Make a version of this calculated field for each quarterly comparison you would like to display:

Q(n-1) Sales calculation in Tableau

We’re almost finished! There’s just one more calculated field. You can think of this formula as building the ground upon which your quarterly sales values will stand. We need to use this as our time axis when building the visual in order to display each quarter correctly.

New Order Date calculation in Tableau

The final step is to put it all together! We can now drag all of our calculated fields into place in the view. The resulting visual is shown below. Note the date setting of New Order Date is continuous days. In the example, I have set each sales value to be quick table calculations showing the running sum of sales.

Final quarterly analysis Tableau viz

More About the Author

Elliott Stam

Platforms Architect
InterWorks Platform 360: Tableau Server Assessments Tailored to You Shooting from the hip is great for western flicks and video games, but when it comes to managing your Tableau Server environment, the ...
A Song of Tableau and Data: Exploring Game of Thrones IMDB Ratings As the masses flock to their couches to re-binge-watch all the episodes of Game of Thrones, salivating for the final season like a pack ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK


Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Geschäftsführer: Mel Stephenson

Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072


Love our blog? You should see our emails. Sign up for our newsletter!