Book Image

Data Modeling with Tableau

By : Kirk Munroe
Book Image

Data Modeling with Tableau

By: Kirk Munroe

Overview of this book

Tableau is unlike most other BI platforms that have a single data modeling tool and enterprise data model (for example, LookML from Google’s Looker). That doesn’t mean Tableau doesn’t have enterprise data governance; it is both robust and highly flexible. This book will help you effectively use Tableau governance models to build a data-driven organization. Data Modeling with Tableau is an extensive guide, complete with step-by-step explanations of essential concepts, practical examples, and hands-on exercises. As you progress through the chapters, you’ll learn the role that Tableau Prep Builder and Tableau Desktop each play in data modeling. You’ll also explore the components of Tableau Server and Tableau Cloud that make data modeling more robust, secure, and performant. Moreover, by extending data models for Ask and Explain Data, you’ll gain the knowledge required to extend analytics to more people in their organizations, leading to better data-driven decisions. Finally, this book will guide you through the entire Tableau stack and the techniques required to build the right level of governance into Tableau data models for the correct use cases. By the end of this Tableau book, you’ll have a firm understanding of how to leverage data modeling in Tableau to benefit your organization.
Table of Contents (22 chapters)
1
Part 1: Data Modeling on the Tableau Platform
4
Part 2: Tableau Prep Builder for Data Modeling
9
Part 3: Tableau Desktop for Data Modeling
14
Part 4: Data Modeling with Tableau Server and Online

Connecting multiple tables to add new columns

Now that we understand the ideal format of data for Tableau, we can look at ways to expand the size of our data model by connecting to multiple tables. We have connected independently to two different tables in this chapter. We will now combine those tables, along with a third table.

There are two ways in which we can add multiple tables to a single data model. The first is by joining data. We join data when we want to add additional columns to our model for additional context. Think of our sales target data. We want to join that data to our SuperStore sales data to add the additional context of sales targets. That will allow analysts to create views to see how the different categories are performing against their targets.

The second way to add additional data to our model is by adding additional rows (with the same columns). The SuperStore data we used earlier in this chapter was for 2022. What if we wanted to add in sales from 2021? That is where a union would be the answer.

For our next exercise, it should be noted that we are creating a relationship to add the new column and not a join. Using a relationship allows Tableau to create the proper join at runtime based on the data being analyzed. You can think of a relationship as a dynamic, smarter join. We will explore the details and differences between relationships and joins in Chapter 7, Chapter 8, and Chapter 9.

To add the additional column of sales target, we will pick up from the end of the previous exercise:

  1. Click on the blue Add hyperlink to the right of Connections:
Figure 1.13 – Clicking the Add hyperlink

Figure 1.13 – Clicking the Add hyperlink

  1. Select To a file | Text file | Superstore Sales 2022.csv | Open.
  2. Under Files, drag Superstore Sales 2022.csv onto the canvas until the orange noodle shows, and then let go.
  3. At this point, Tableau tries to create a relationship between these tables. Sometimes, Tableau can figure out how to create this relationship. In this case, we can see Tableau was unable to do this from the exclamation mark in a red triangle:
Figure 1.14 – Creating a relationship between two tables

Figure 1.14 – Creating a relationship between two tables

  1. We need to tell Tableau that the two relationships it should create are Date with Order Date and Category with Category. Let’s relate the two category fields first. We do this by selecting Category and Category1 and making sure the operator is set to equals (=):
Figure 1.15 – Creating a relationship by linking fields

Figure 1.15 – Creating a relationship by linking fields

  1. To complete the relationship, we will also need to link Date fields to ensure that the sales targets are aligned with the proper dates for analysis. In this specific case, the dates are not at the same grain (one is at the month level and one is at the day level). This will require us to create a relationship calculation, which we will explore in future chapters.
  2. Now that we have joined additional data sources (tables) to add additional columns for analysis, we will explore adding new rows of data through a union.
  3. Hover your cursor on the right side of the Superstore Sales 2022.csv file rectangle on the canvas, and click on the down arrow when it appears. Select Convert to Union…:
Figure 1.16 – Convert to Union…

Figure 1.16 – Convert to Union…

  1. Drag the Superstore Sales 2021.csv file from the files section on the canvas into the union dialog box. After clicking OK, all the rows from both 2021 and 2022 will be available for analysis:
Figure 1.17 – Dragging files to the union dialog box

Figure 1.17 – Dragging files to the union dialog box

We have now covered the two core methods of expanding our data model through relationships and unions.