Tableau Class Notes: To Aggregate or Not to Aggregate? Part 2


Tableau Class Notes: To Aggregate or Not to Aggregate? Part 2

As a follow-up to my prior blog post, I wanted to explore an additional use case for aggregation in Tableau: joining together data that might be at different date levels. It’s the same premise—you have two data sources at two levels of detail (e.g. row-level transactions vs. regional goals; employee-level vs. team-level), but the steps to aggregate that data are slightly different.

In this example, we have weekly profit data, as well as daily sales data. Our end goal is to return three columns with our daily sales rolled up to the weekly level so that we can compare it against our profits:

weekly and daily profit data in Tableau

Since one data source is at the weekly level, and one is at the daily level, adding an aggregation will be necessary to return data at the correct level.

When Aggregation is Necessary

A rule of thumb for aggregation: your data sources must be aggregated so that they match the data source with the highest level of aggregation. In our example, we have our data split out by week and by day. We couldn’t reliably break our weekly data down to the daily level since we don’t know what days each profit occurred on, so we should aggregate our daily data to the weekly level.

Once we add an Aggregate step, we need to specify what fields we are grouping by and what we are aggregating:

grouped and aggregated fields in Tableau

Click on the word Group next to your data type icon to change your “Group By” level to “Week Start” so it matches our Weekly target data. If you want to read more about how Tableau treats our different options, check out this video from my colleague, Katie! Next, we can add a Clean step and join our two data sources together on our two date fields to get our final data source:

clean aggregated data in Tableau

Hopefully this clears up any questions you have about how to tackle situations where you might have data at two different date levels. Cleaning it up in Prep before you bring it into Tableau Desktop will make your life infinitely easier by minimizing the need for calculations. Thanks to Kent Sloan for assistance on this blog, and thanks for reading!

More About the Author

Liz Jensen

Analytics Consultant
Alter Your Analysis: Unofficial Holidays We know what dates Halloween, Christmas, and US Independence Day are on. But what about National Dogs in Politics Day or National ...
Alter Your Analysis: Women’s World Cup Match Wins In this second installment of Alter Your Analysis, I am tackling Alteryx’s Weekly Challenge 169: “Using the values in the attached file ...

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!