Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Data Modeling with Tableau

You're reading from   Data Modeling with Tableau A practical guide to building data models using Tableau Prep and Tableau Desktop

Arrow left icon
Product type Paperback
Published in Dec 2022
Publisher Packt
ISBN-13 9781803248028
Length 356 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Kirk Munroe Kirk Munroe
Author Profile Icon Kirk Munroe
Kirk Munroe
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Preface 1. Part 1: Data Modeling on the Tableau Platform
2. Chapter 1: Introducing Data Modeling in Tableau FREE CHAPTER 3. Chapter 2: Licensing Considerations and Types of Data Models 4. Part 2: Tableau Prep Builder for Data Modeling
5. Chapter 3: Data Preparation with Tableau Prep Builder 6. Chapter 4: Data Modeling Functions with Tableau Prep Builder 7. Chapter 5: Advanced Modeling Functions in Tableau Prep Builder 8. Chapter 6: Data Output from Tableau Prep Builder 9. Part 3: Tableau Desktop for Data Modeling
10. Chapter 7: Connecting to Data in Tableau Desktop 11. Chapter 8: Building Data Models Using Relationships 12. Chapter 9: Building Data Models at the Physical Level 13. Chapter 10: Sharing and Extending Tableau Data Models 14. Part 4: Data Modeling with Tableau Server and Online
15. Chapter 11: Securing Data 16. Chapter 12: Data Modeling Considerations for Ask Data and Explain Data 17. Chapter 13: Data Management with Tableau Prep Conductor 18. Chapter 14: Scheduling Extract Refreshes 19. Chapter 15: Data Modeling Strategies by Audience and Use Case 20. Index 21. Other Books You May Enjoy

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.

You have been reading a chapter from
Data Modeling with Tableau
Published in: Dec 2022
Publisher: Packt
ISBN-13: 9781803248028
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image