Master Tableau From Scratch

Learn Tableau fundamentals, data connections, data preparation, filtering, data modeling, calculations, LOD expressions, visualizations, dashboards, and storytelling through structured practical lessons.

COURSE SYLLABUS

Tableau Relationships

Learn how Tableau connects multiple tables using logical relationships while preserving each table's level of detail.

1. What are Tableau Relationships?

Tableau Relationships are a way to connect tables from different data sources or from the same data source without physically merging them into a single table.

Relationships are created in Tableau's logical layer. Each table remains an independent logical table. Tableau determines how to query the related tables based on the fields used in a visualization.

Key Characteristics

  • Tables remain separate in the logical data model.
  • Relationships are based on matching fields.
  • Tableau generates context-aware queries during analysis.
  • Different levels of detail can be preserved.
  • Relationship behavior depends on the fields used in the view.

2. Understanding the Logical Layer

The logical layer is the top-level data model in Tableau. When you create a relationship, you connect logical tables without combining their physical rows into one table.

Customers Customer ID Customer Name City Orders Order ID Customer ID Sales Relationship Customer ID Separate logical tables connected by matching fields

Logical tables stay separate and are related through a common field.

Remember: A relationship does not immediately merge table rows. Tableau decides how to query the data when a worksheet requires fields from related tables.

3. Example: Customers and Orders

Consider a business database containing two tables: Customers and Orders. Both tables contain the Customer ID field.

Customers Table

Customer ID Customer Name City
101RahulPune
102PriyaMumbai
103AmitNashik

Orders Table

Order ID Customer ID Sales
5001101₹5,000
5002101₹3,000
5003102₹7,000
5004103₹2,000

Relationship Configuration

First table: Customers

Second table: Orders

Matching field: Customer ID

Typical cardinality: One-to-Many

One customer can have multiple orders, while each order normally belongs to one customer.

Customer 101 Rahul Order 5001 Sales: ₹5,000 Order 5002 Sales: ₹3,000 One customer Many orders

One customer can be associated with multiple order records.

4. Cardinality in Relationships

Cardinality describes how records in one table relate to records in another table. Tableau provides One and Many settings for each side of a relationship.

Cardinality Meaning Example
One-to-One One record matches one record. Employee and Employee Profile
One-to-Many One record can match multiple records. Customer and Orders
Many-to-Many Multiple records can match multiple records. Students and Courses
Important: Set cardinality according to the actual data. Incorrect cardinality assumptions can affect query optimization and aggregation results.

5. Referential Integrity

Referential integrity describes whether records in one table are expected to have matching records in the related table.

All Records Match

Use this setting when every record in one table is expected to have a corresponding record in the related table.

Example: Every order is expected to reference an existing customer.

Some Records Match

Use this setting when some records may not have a matching record in the related table.

Example: A customer table may contain customers who have not placed any orders.

Customers Orders Customer 101 Customer 102 Customer 103 Order 5001 → 101 Order 5002 → 101 Order 5003 → 102 Customer 103 has no matching order in this example

Some customers may have no matching order records.

The correct setting depends on the data and the assumptions you can safely make. Available relationship options can also depend on the connector and data source.

6. Relationships vs Physical Joins

Relationships and joins both connect tables, but they work at different levels of Tableau's data model.

Feature Relationships Physical Joins
Data model layer Logical layer Physical layer
Table behavior Tables remain separate logical tables. Rows are combined into one logical table.
Query behavior Tableau generates context-aware queries. Join is defined in the physical data model.
Level of detail Can preserve different levels of detail. Can change row-level detail through the join.
Common use Connecting tables for flexible analysis. When a single combined table is required.
Relationships Customers Orders Separate logical tables Physical Join Combined Table Customer + Order columns Rows combined using join rules

Relationships connect logical tables; physical joins combine rows.

Best practice: Prefer relationships when you need to analyze tables at different levels of detail. Use physical joins when you specifically need a combined physical table.

7. How to Create a Relationship in Tableau

  1. Open Tableau Desktop.
  2. Connect to your database or data source.
  3. Open the Data Source page.
  4. Drag the Customers table onto the logical canvas.
  5. Drag the Orders table next to the Customers table.
  6. Tableau creates a relationship between the tables.
  7. Click the relationship line to configure matching fields.
  8. Select Customer ID as the matching field in both tables.
  9. Review cardinality and referential integrity settings.
  10. Open a worksheet and use fields from both tables.

Configuration Example

Table 1: Customers
Matching Field: Customer ID

Table 2: Orders
Matching Field: Customer ID

Cardinality:
Customers = One
Orders = Many

Relationship:
Customers.Customer ID = Orders.Customer ID

8. Common Issues and Best Practices

Common Issues

  • Incorrect matching fields: Selecting the wrong fields can produce unexpected analysis results.
  • Different data types: Matching fields should have compatible data types.
  • Duplicate identifiers: Duplicate values can affect the expected cardinality.
  • Unmatched records: Missing matching records can affect which values appear in a view.
  • Incorrect relationship settings: Wrong cardinality or referential integrity assumptions can affect query optimization and aggregation behavior.

Best Practices

  • Understand the grain of each table before creating relationships.
  • Use the correct matching fields.
  • Check for null and duplicate key values.
  • Set cardinality based on actual data characteristics.
  • Choose referential integrity settings carefully.
  • Validate totals and aggregations in worksheets.
  • Use relationships for flexible analysis across different levels of detail.

Summary

Tableau Relationships connect tables in the logical layer while keeping them as separate logical tables. Tableau generates context-aware queries during analysis based on the fields used in a visualization. Cardinality describes how records relate between tables, while referential integrity describes whether matching records are expected. Unlike physical joins, relationships do not directly combine table rows into one logical table. Choosing the correct relationship settings and validating your data helps maintain accurate analysis and aggregations.