Quantcast
Channel: Tableau | Salesforce Ben
Viewing all articles
Browse latest Browse all 12

Tableau Order of Operations: An Overview

$
0
0

If you work with Tableau, you will be aware of the potential intricacies involved when applying correct dimensions and measures to produce the views you want. I can recall several occasions when analysis was not providing aggregated data in a way I was expecting, which left me throwing my hands up in despair! This was until I learned about Tableau Order of Operations.

In this guide, you will learn about the order that Tableau executes your queries in, with some examples to help you gain an overall understanding of this pipeline. The information below is ideal for those with a working knowledge of Tableau, but it can also work as a brief introduction to Tableau to help you pick up the concepts quickly.

What Is Tableau Order of Operations?

As you build your dashboard and add more dimensional data to the visualizations, more actions are executed by Tableau. These have to be done in a certain order and that’s why it’s named “Order of Operations”. Understanding how the query pipeline works in the background will set you up for good.

The principal is quite similar to learning Order of Operations in math at school. Some of you might know it as BODMAS (or PEDMAS). Calculating in order of brackets, orders, divisions, multiplications, additions, and subtractions are steps of actions to take to calculate the correct value in a problem set. In a similar way, Tableau is executing actions in a predefined order. All there is to do is ensure that the ordering is reflected in your dashboard development.

In What Order Will Tableau Execute Your Data Querying?

Tableau will execute filters in the order shown above. There are six key filter categories to consider, with several calculations that are dependent on data aggregation choices by the user. I will explain these in more detail below.

1. Extract Filters

An extract is a subset of an original data source that has been edited and saved for the purpose of either of the following reasons:

  • Improving performance of a dashboard (due to loading less data).
  • Performing additional functionalities that are not supported with the original dataset (e.g. calculating a median of a value field).

In addition, Data Extracts are great for working offline when you don’t have access to relevant data and file shares.

This would be the very first step of any type of filtering that can be done to your data. You sort, filter, and save data as an Extract and connect to it as a completely different datasource. Later on, after connecting Tableau dashboard to this Extract, we assume that the data filters applied will take precedence over any other actions.

2. Data Source Filters

As you connect to a piece of data (Salesforce, Excel, Microsoft SQL, etc.) the “Data Source” tab will refresh and display the full set of data in question. You can actually apply filters here at source level – this means that, when you are using the data set later in a sheet, you only analyze data that was deemed relevant.

You may ask the reason for doing this. It’s to reduce overhead when trying to filter your data outside Tableau. For example, if you only want to see the sales orders made in the year 2017 and beyond, but the data set shows data three years prior to 2017, having to create a new spreadsheet and then make a connection in Tableau is an admin expense. And what if you change your mind later? It’s all about building robustness into your work.

To apply datasource filters, select Add at the top-right corner in the datasource tab where a pop-up window will allow you to make your selections. This way, before you move on to creating a new sheet and starting to visualize the data, filters would have been applied already.

I would say that Data Extracts and Data Source Filters are much easier to grasp when understanding Order of Operations. This is because both of these happen outside dashboard development – even before you start a brand new sheet. The order of next items on the action list are more important to acknowledge, and it’s where data filtering within dashboard development becomes more complex.

3. Context Filters

You must be quite familiar with drag-and-drop filters on the Marks card (these are your Dimensions and Measures). Dimension and Measure filters will filter data at row level. If you are not interested in seeing data before 2017, each row containing anything before this year will be excluded. Context filters ensure that data is filtered before you even get to individual filters. You’ll spot context filters when the filter itself turns gray.

You will have to right-click the dimension filter to add or remove from context (as shown above).

At this point you may begin to ask: why not filter data at the datasource level? A dashboard is a set of sheets combined in one view. Each sheet is independent and will be exploring discrete insights. One sheet view may be displaying a line graph of five year annual profits selling Furniture, and another the same but focusing on Office Supplies. Both of these views require different product data. Any filtering will have to be done at sheet level, not datasource.

Common Hurdle

I wouldn’t necessarily call this a problem – just a slight complexity around the order of query execution. It all comes down to whether a Dimension needs a common filter or context filter. Let’s look at two examples:

Basic Dimension Filter (Figure 1)
Dimension Filter added to Context (Figure 2)

The two figures above are looking at the sum of sales fixed to a sub-category. Note that the view differs between the figures: Region = Central filter and Region = Central added to Context. Remember that Context filters will filter your data prior dimension filters.

So, what is this really telling us? With the Context filter we have selected the data to only show the Central Region, therefore the sum of sales per Sub-Category is only for the Central Region. In contrast, because data was fixed to the Sub-Category, the view will display the total sales per region regardless of the dimension filter.

Tableau will cover Sets, Conditional and Top N, and Fixed Level of Detail Calculations before Dimension Filters. This is where it is vital to know what insights and outcomes you are expecting to see (and want to display), should you present whole values or filter data with context filters.

4. Dimension Filters

We finally get to something we are familiar with – Dimension filters (I like to call these qualitative data), which will take priority over Measures (quantitative data). The reason for this is simple; before we can apply measures to our dataset, Tableau needs to know what elements are involved in aggregations (e.g. calculations based on certain sales Locations or product Categories).

Common Hurdle

Of course, the intricacy of the query pipeline does not end here. Any of the Include or Exclude Level of Detail Operations and Data Blending will take place just before Measure Filters. This is to ensure that we don’t filter out values that are important for the analysis. Using the same example as in figures 1 & 2, let’s calculate Include Level of detail per Sub-Category to sum of sales, and filter to Central Region.

As you can see above, we saw the same results as we did with Fixed LOD calculation when adding Region into context. This is because the Include filter occurs after dimension filters have taken place.

5. Measure Filters

It’s time for any quantitative data to execute, which is pretty straight forward. Just take a step back to think about how many actions had to be taken to arrive at this point. This is what makes it so complex to get the right results. Understanding what you want from your data is key. If you know what insights you’re trying to gather, you’ll use Tableau Order of Operations as a guide to assemble data in the way the software is hardcoded to do.

6. Table Calculation Filters

Just before we move on to filters based on Table Calculations, any Forecasts, Table Calculations, Clusters, and Totals will be applied to the view first. This ensures that the actual calculations are completed before filtering can take place.

Finally, if you’re interested in displaying any Trend or Reference lines, these are last in the order.

Useful Advice

As analysts, Tableau Order of Operations is not something we necessarily look at because dashboards may not be calculation intensive. And when it comes to actually using it, I often go ‘back to basics’ to ensure I’ve applied it correctly. Use this as a guide as needed – it’s not necessary to know this off by heart.

The biggest piece of advice is to test your data. Once you have a prototype of what you want to measure and visualize, always take a subset of data and make your own assumptions. Is this what I’m expecting? Does it make sense? Try calculating – even if it involves using pen and paper. It is not testing if Tableau is doing what it said it would but ensuring you’ve aggregated data to match the requirements of the task.

Summary

Overall, this has been an introduction to Tableau Order of Operations, the steps taken to execute your analytics queries with a few examples. Of course there is so much more that Tableau has to offer. There are vast amounts of rules, tips and tricks.

Note: All data used in the examples above is publicly available via Tableau Public.

READ MORE: 5 New Features in Tableau’s 2022.3 Release

The post Tableau Order of Operations: An Overview appeared first on Salesforce Ben.


Viewing all articles
Browse latest Browse all 12

Trending Articles