In the Manage Relationships box, click New. In the Create Relationship box, click the arrow for Table, and select a table from the list. In a one-to-many. For Column (Foreign), select the column that contains the data that is related to Related Column (Primary). For Related Table. How to Put Two Graphs Together in Excel on a Mac. Microsoft Excel charts transform raw numbers into visualizations that clarify the relationships among your data and help reveal underlying trends. Some worksheets combine values that interrelate but that include more than one type of information. Whether you want to.

-->

When you import multiple tables, chances are you'll do some analysis using data from all those tables. Relationships between those tables are necessary to accurately calculate results and display the correct information in your reports. Power BI Desktop makes creating those relationships easy. In fact, in most cases you won’t have to do anything, the autodetect feature does it for you. However, sometimes you might have to create relationships yourself, or need to make changes to a relationship. Either way, it’s important to understand relationships in Power BI Desktop and how to create and edit them.

Autodetect during load

If you query two or more tables at the same time, when the data is loaded, Power BI Desktop attempts to find and create relationships for you. The relationship options Cardinality, Cross filter direction, and Make this relationship active are automatically set. Power BI Desktop looks at column names in the tables you're querying to determine if there are any potential relationships. If there are, those relationships are created automatically. If Power BI Desktop can't determine with a high level of confidence there's a match, it doesn't create the relationship. However, you can still use the Manage relationships dialog box to manually create or edit relationships.

Create a relationship with autodetect

On the Home tab, select Manage Relationships > Autodetect.

Create a relationship manually

  1. On the Home tab, select Manage Relationships > New.

  2. In the Create relationship dialog box, in the first table drop-down list, select a table. Select the column you want to use in the relationship.

  3. In the second table drop-down list, select the other table you want in the relationship. Select the other column you want to use, and then elect OK.

By default, Power BI Desktop automatically configures the options Cardinality (direction), Cross filter direction, and Make this relationship active for your new relationship. However, you can change these settings if necessary. For more information, see Understanding additional options.

If none of the tables selected for the relationship has unique values, you'll see the following error: One of the columns must have unique values. At least one table in a relationship must have a distinct, unique list of key values, which is a common requirement for all relational database technologies.

If you encounter that error, there are a couple ways to fix the issue:

  • Use Remove Duplicates to create a column with unique values. The drawback to this approach is that you might lose information when duplicate rows are removed; often a key (row) is duplicated for good reason.
  • Add an intermediary table made of the list of distinct key values to the model, which will then be linked to both original columns in the relationship.

For more information, see this blog post.

Edit a relationship

  1. On the Home tab, select Manage Relationships.

  2. In the Manage relationships dialog box, select the relationship, then select Edit.

Configure additional options

When you create or edit a relationship, you can configure additional options. By default, Power BI Desktop automatically configures additional options based on its best guess, which can be different for each relationship based on the data in the columns.

Cardinality

The Cardinality option can have one of the following settings:

Many to one (*:1): A many-to-one relationship is the most common, default type of realtionship. It means the column in a given table can have more than one instance of a value, and the other related table, often know as the lookup table, has only one instance of a value.

One to one (1:1): In a one-to-one relationship, the column in one table has only one instance of a particular value, and the other related table has only one instance of a particular value.

One to many (1:*): In a one-to-many relationship, the column in one table has only one instance of a particular value, and the other related table can have more than one instance of a value.

Many to many (*:*): With composite models, you can establish a many-to-many relationship between tables, which removes requirements for unique values in tables. It also removes previous workarounds, such as introducing new tables only to establish relationships. For more information, see Relationships with a many-many cardinality.

For more information about when to change cardinality, see Understanding additional options.

Cross filter direction

The Cross filter direction option can have one the following settings:

Both: For filtering purposes, both tables are treated as if they're a single table. The Both setting works well with a single table that has a number of lookup tables that surround it. An example is a sales actuals table with a lookup table for its department. This configuration is often called a star schema configuration (a central table with several lookup tables). However, if you have two or more tables that also have lookup tables (with some in common) then you wouldn't want to use the Both setting. To continue the previous example, in this case, you also have a budget sales table that records target budget for each department. And, the department table is connected to both the sales and the budget table. Avoid the Both setting for this kind of configuration.

Single: The most common, default direction, which means filtering choices in connected tables work on the table where values are being aggregated. If you import a Power Pivot in Excel 2013 or earlier data model, all relationships will have a single direction.

For more information about when to change cross filter direction, see Understanding additional options.

Make this relationship active

When checked, the relationship serves as the active, default relationship. In cases where there is more than one relationship between two tables, the active relationship provides a way for Power BI Desktop to automatically create visualizations that include both tables.

For more information about when to make a particular relationship active, see Understanding additional options.

Understanding relationships

Once you've connected two tables together with a relationship, you can work with the data in both tables as if they were a single table, freeing you from having to worry about relationship details, or flattening those tables into a single table before importing them. In many situations, Power BI Desktop can automatically create relationships for you. However, if Power BI Desktop can’t determine with a high-degree of certainty that a relationship between two tables should exist, it doesn't automatically create the relationship. In that case, you must do so.

Let’s go through a quick tutorial, to better show you how relationships work in Power BI Desktop.

Tip

You can complete this lesson yourself:

  1. Copy the following ProjectHours table into an Excel worksheet (excluding the title), select all of the cells, and then select Insert > Table.
  2. In the Create Table dialog box, select OK.
  3. Select any table cell, select Table Design > Table Name, and then enter ProjectHours.
  4. Do the same for the CompanyProject table.
  5. Import the data by using Get Data in Power BI Desktop. Select the two tables as a data source, and then select Load.

The first table, ProjectHours, is a record of work tickets that record the number of hours a person has worked on a particular project.

Tables

ProjectHours

TicketSubmittedByHoursProjectDateSubmit
1001Brewer, Alan22Blue1/1/2013
1002Brewer, Alan26Red2/1/2013
1003Ito, Shu34Yellow12/4/2012
1004Brewer, Alan13Orange1/2/2012
1005Bowen, Eli29Purple10/1/2013
1006Bento, Nuno35Green2/1/2013
1007Hamilton, David10Yellow10/1/2013
1008Han, Mu28Orange1/2/2012
1009Ito, Shu22Purple2/1/2013
1010Bowen, Eli28Green10/1/2013
1011Bowen, Eli9Blue10/15/2013

This second table, CompanyProject, is a list of projects with an assigned priority: A, B, or C.

CompanyProject

ProjNamePriority
BlueA
RedB
GreenC
YellowC
PurpleB
OrangeC

Notice that each table has a project column. Each is named slightly different, but the values look like they’re the same. That’s important, and we’ll get back to it in soon.

Now that we have our two tables imported into a model, let’s create a report. The first thing we want to get is the number of hours submitted by project priority, so we select Priority and Hours from the Fields pane.

If we look at our table in the report canvas, you’ll see the number of hours is 256 for each project, which is also the total. Clearly this number isn’t correct. Why? It’s because we can’t calculate a sum total of values from one table (Hours in the Project table), sliced by values in another table (Priority in the CompanyProject table) without a relationship between these two tables.

So, let’s create a relationship between these two tables.

Remember those columns we saw in both tables with a project name, but with values that look alike? We'll use these two columns to create a relationship between our tables.

Why these columns? Well, if we look at the Project column in the ProjectHours table, we see values like Blue, Red, Yellow, Orange, and so on. In fact, we see several rows that have the same value. In effect, we have many color values for Project.

If we look at the ProjName column in the CompanyProject table, we see there’s only one of each of the color values for the project name. Each color value in this table is unique, and that’s important, because we can create a relationship between these two tables. In this case, a many-to-one relationship. In a many-to-one relationship, at least one column in one of the tables must contain unique values. There are some additional options for some relationships, which we'll look at later. For now, let’s create a relationship between the project columns in each of our two tables.

To create the new relationship

Excel For Mac Create Relationship Between Tables
  1. Select Manage Relationships from the Home tab.

  2. In Manage relationships, select New to open the Create relationship dialog box, where we can select the tables, columns, and any additional settings we want for our relationship.

  3. In the first drop-down list, select ProjectHours as the first table, then select the Project column. This side is the many side of our relationship.

  4. In the second drop-down list, CompanyProject is preselected as the second table. Select the ProjName column. This side is the one side of our relationship.

  5. Accept the defaults for the relationship options, and then select OK.

  6. In the Manage relationships dialog box, select Close.

In the interest of full disclosure, you just created this relationship the hard way. You could have just selected Autodetect in the Manage relationships dialog box. In fact, autodetect would have automatically created the relationship for you when you loaded the data if both columns had the same name. But, what’s the challenge in that?

Now, let’s look at the table in our report canvas again.

That looks a whole lot better, doesn’t it?

When we sum up hours by Priority, Power BI Desktop looks for every instance of the unique color values in the CompanyProject lookup table, looks for every instance of each of those values in the ProjectHours table, and then calculates a sum total for each unique value.

That was easy. In fact, with autodetect, you might not even have to do that much.

Understanding additional options

When a relationship is created, either with autodetect or one you create manually, Power BI Desktop automatically configures additional options based on the data in your tables. These additional relationship options are located in the lower portion of the Create relationship and Edit relationship dialog boxes.

Power BI typically sets these options automatically and you won’t need to adjust them; however, there are several situations where you might want to configure these options yourself.

Automatic relationship updates

You can manage how Power BI treats and automatically adjusts relationships in your reports and models. To specify how Power BI handles relationships options, select File > Options and settings > Options from Power BI Desktop, and then select Data Load in the left pane. The options for Relationships appear.

There are three options that can be selected and enabled:

  • Import relationships from data sources on first load: This option is selected by default. When it's selected, Power BI checks for relationships defined in your data source, such as foreign key/primary key relationships in your data warehouse. If such relationships exist, they're mirrored into the Power BI data model when you initially load data. This option enables you to quickly begin working with your model, rather than requiring you find or define those relationships yourself.

  • Update or delete relationships when refreshing data: This option is unselected by default. If you select it, Power BI checks for changes in data source relationships when your dataset is refreshed. If those relationships changed or are removed, Power BI mirrors those changes in its own data model, updating or deleting them to match.

    Warning

    If you're using row-level security that relies on the defined relationships, we don't recommend selecting this option. If you remove a relationship that your RLS settings rely on, your model might become less secure.

  • Autodetect new relationships after data is loaded: This option is described in Autodetect during load.

Future updates to the data require a different cardinality

Normally, Power BI Desktop can automatically determine the best cardinality for the relationship. If you do need to override the automatic setting, because you know the data will change in the future, you can change it with the Cardinality control. Let’s look at an example where we need to select a different cardinality.

The CompanyProjectPriority table is a list of all company projects and their priority. The ProjectBudget table is the set of projects for which a budget has been approved.

CompanyProjectPriority

Tables
ProjNamePriority
BlueA
RedB
GreenC
YellowC
PurpleB
OrangeC

ProjectBudget

Approved ProjectsBudgetAllocationAllocationDate
Blue40,00012/1/2012
Red100,00012/1/2012
Green50,00012/1/2012

If we create a relationship between the Approved Projects column in the ProjectBudget table and the ProjectName column in the CompanyProjectPriority table, Power BI automatically sets Cardinality to One to one (1:1) and Cross filter direction to Both.

The reason Power BI makes these settings is because, to Power BI Desktop, the best combination of the two tables is as follows:

ProjNamePriorityBudgetAllocationAllocationDate
BlueA40,00012/1/2012
RedB100,00012/1/2012
GreenC50,00012/1/2012
YellowC

PurpleB

OrangeC

There's a one-to-one relationship between our two tables because there are no repeating values in the combined table’s ProjName column. The ProjName column is unique, because each value occurs only once; therefore, the rows from the two tables can be combined directly without any duplication.

But, let’s say you know the data will change the next time you refresh it. A refreshed version of the ProjectBudget table now has additional rows for the Blue and Red projects:

ProjectBudget

Approved ProjectsBudgetAllocationAllocationDate
Blue40,00012/1/2012
Red100,00012/1/2012
Green50,00012/1/2012
Blue80,0006/1/2013
Red90,0006/1/2013

These additional rows mean the best combination of the two tables now looks like this:

ProjNamePriorityBudgetAllocationAllocationDate
BlueA40,00012/1/2012
RedB100,00012/1/2012
GreenC50,00012/1/2012
YellowC

PurpleB

OrangeC

BlueA800006/1/2013
RedB900006/1/2013

In this new combined table, the ProjName column has repeating values. The two original tables won’t have a one-to-one relationship once the table is refreshed. In this case, because we know those future updates will cause the ProjName column to have duplicates, we want to set the Cardinality to be Many to one (*:1), with the many side on ProjectBudget and the one side on CompanyProjectPriority.

Adjusting Cross filter direction for a complex set of tables and relationships

For most relationships, the cross filter direction is set to Both. There are, however, some more uncommon circumstances where you might need to set this option differently from the default, like if you’re importing a model from an older version of Power Pivot, where every relationship is set to a single direction.

The Both setting enables Power BI Desktop to treat all aspects of connected tables as if they're a single table. There are some situations, however, where Power BI Desktop can't set a relationship’s cross filter direction to Both and also keep an unambiguous set of defaults available for reporting purposes. If a relationship cross filter direction isn't set to Both, then it’s usually because it would create ambiguity. If the default cross filter setting isn’t working for you, try setting it to a particular table or to Both.

Single direction cross filtering works for many situations. In fact, if you’ve imported a model from Power Pivot in Excel 2013 or earlier, all of the relationships will be set to single direction. Single direction means that filtering choices in connected tables work on the table where aggregation work is happening. Sometimes, understanding cross filtering can be a little difficult, so let’s look at an example.

With single direction cross filtering, if you create a report that summarizes the project hours, you can then choose to summarize (or filter) by the CompanyProject table and its Priority column or the CompanyEmployee table and its City column. If however, you want to count the number of employees per projects (a less common question), it won’t work. You’ll get a column of values that are all the same. In the following example, both relationship's cross filtering direction is set to a single direction: towards the ProjectHours table. In the Values well, the Project field is set to Count:

Excel For Mac Create Relationship Between Tables

Filter specification will flow from CompanyProject to ProjectHours (as shown in the following image), but it won’t flow up to CompanyEmployee.

However, if you set the cross filtering direction to Both, it will work. The Both setting allows the filter specification to flow up to CompanyEmployee.

With the cross filtering direction set to Both, our report now appears correct:

Cross filtering both directions works well for a pattern of table relationships such as the pattern above. This schema is most commonly called a star schema, like this:

Cross filtering direction does not work well with a more general pattern often found in databases, like in this diagram:

If you have a table pattern like this, with loops, then cross filtering can create an ambiguous set of relationships. For instance, if you sum up a field from TableX and then choose to filter by a field on TableY, then it’s not clear how the filter should travel, through the top table or the bottom table. A common example of this kind of pattern is with TableX as a sales table with actuals data and for TableY to be budget data. Then, the tables in the middle are lookup tables that both tables use, such as division or region.

As with active/inactive relationships, Power BI Desktop won’t allow a relationship to be set to Both if it will create ambiguity in reports. There are several different ways you can handle this situation. Here are the two most common:

  • Delete or mark relationships as inactive to reduce ambiguity. Then, you might be able to set a relationship cross filtering as Both.
  • Bring in a table twice (with a different name the second time) to eliminate loops. Doing so makes the pattern of relationships like a star schema. With a star schema, all of the relationships can be set to Both.

Wrong active relationship

When Power BI Desktop automatically creates relationships, it sometimes encounters more than one relationship between two tables. When this situation happens, only one of the relationships is set to be active. The active relationship serves as the default relationship, so that when you choose fields from two different tables, Power BI Desktop can automatically create a visualization for you. However, in some cases the automatically selected relationship can be wrong. Use the Manage relationships dialog box to set a relationship as active or inactive, or set the active relationship in the Edit relationship dialog box.

To ensure there’s a default relationship, Power BI Desktop allows only a single active relationship between two tables at a given time. Therefore, you must first set the current relationship as inactive and then set the relationship you want to be active.

Let’s look at an example. The first table is ProjectTickets, and the second table is EmployeeRole.

ProjectTickets

TicketOpenedBySubmittedByHoursProjectDateSubmit
1001Perham, TomBrewer, Alan22Blue1/1/2013
1002Roman, DanielBrewer, Alan26Red2/1/2013
1003Roth, DanielIto, Shu34Yellow12/4/2012
1004Perham, TomBrewer, Alan13Orange1/2/2012
1005Roman, DanielBowen, Eli29Purple10/1/2013
1006Roth, DanielBento, Nuno35Green2/1/2013
1007Roth, DanielHamilton, David10Yellow10/1/2013
1008Perham, TomHan, Mu28Orange1/2/2012
1009Roman, DanielIto, Shu22Purple2/1/2013
1010Roth, DanielBowen, Eli28Green10/1/2013
1011Perham, TomBowen, Eli9Blue10/15/2013

EmployeeRole

EmployeeRole
Bento, NunoProject Manager
Bowen, EliProject Lead
Brewer, AlanProject Manager
Hamilton, DavidProject Lead
Han, MuProject Lead
Ito, ShuProject Lead
Perham, TomProject Sponsor
Roman, DanielProject Sponsor
Roth, DanielProject Sponsor

There are actually two relationships here:

  • Between Employee in the EmployeeRole table and SubmittedBy in the ProjectTickets table.
  • Between OpenedBy in the ProjectTickets table and Employee in the EmployeeRole table.

If we add both relationships to the model (OpenedBy first), then the Manage relationships dialog box shows that OpenedBy is active:

Now, if we create a report that uses Role and Employee fields from EmployeeRole, and the Hours field from ProjectTickets in a table visualization in the report canvas, we see only project sponsors because they’re the only ones that opened a project ticket.

We can change the active relationship and get SubmittedBy instead of OpenedBy. In Manage relationships, uncheck the ProjectTickets(OpenedBy) to EmployeeRole(Employee) relationship, and then check the EmployeeRole(Employee) to Project Tickets(SubmittedBy) relationship.

See all of your relationships in Relationship view

Sometimes your model has multiple tables and complex relationships between them. Relationship view in Power BI Desktop shows all of the relationships in your model, their direction, and cardinality in an easy to understand and customizable diagram.

To learn more, see Work with Relationship view in Power BI Desktop.

Relationships are a dynamic, flexible way to combine data from multiple tables for analysis. A relationship describes how two tables relate to each other, based on common fields, but does not merge the tables together. When a relationship is created between tables, the tables remain separate, maintaining their individual level of detail and domains.

Think of a relationship as a contract between two tables. When you are building a viz with fields from these tables, Tableau brings in data from these tables using that contract to build a query with the appropriate joins.

Learn more: The ability to relate your data is an important feature of Tableau's new data modeling capabilities. For more information, see What's Changed with Data Sources and Analysis. Learn more about how relationships work in these Tableau blog posts:

Watch a video: For an overview of data source enhancements and an introduction to using relationships in Tableau, see this 5-minute video.

What are relationships?

Relationships are the flexible, connecting lines created between the logical tables in your data source. Some people affectionately call relationships 'noodles', but we usually refer to them as 'relationships' in our help documentation.

We recommend using relationships as your first approach to combining your data because it makes data preparation and analysis easier and more intuitive. Use joins only when you absolutely need to(Link opens in a new window).

Relationships provide several advantages over using joins for multi-table data:

Excel For Mac Create Relationship Between Tables Online

  • You don't need to configure join types between tables. You only need to select the fields to define the relationship.
  • Related tables remain separate and distinct; they are not merged into a single table.
  • Relationships use joins, but they are automatic. Tableau automatically selects join types based on the fields being used in the visualization. During analysis, Tableau adjusts join types intelligently and preserves the native level of detail in your data.
  • Tableau uses relationships to generate correct aggregations and appropriate joins during analysis, based on the current context of the fields in use in a worksheet.
  • Multiple tables at different levels of detail are supported in a single data source. You can build data models that contain more tables, and reduce the number of data sources needed to build a viz.
  • Unmatched measure values are not dropped (no accidental loss of data).
  • Avoids data duplication and filtering issues that can sometimes result from joins.
  • Tableau will generate queries only for the data that is relevant to the current view.

For related information, see:

Requirements for relationships

  • When relating tables, the fields that define the relationships must have the same data type.
  • You can't define relationships based on geographic fields.
  • Circular relationships aren't supported in the data model.
  • You can't edit relationships in a published data source.
  • You can't define relationships between published data sources.
  • Your workbook must use an embedded data source for you to be able to edit relationships and performance options in the Data Source page in Tableau Online or Tableau Server.

Factors that limit the benefits of using related tables:

  • Dirty data in tables (i.e. tables that weren't created with a well-structured model in mind and contain a mix of measures and dimensions in multiple tables) can make multi-table analysis more complex.
  • Using data source filters will limit Tableau's ability to do join culling in the data. Join culling is a term for how Tableau simplifies queries by removing unnecessary joins.
  • Tables with a lot of unmatched values across relationships.
  • Interrelating multiple fact tables with multiple dimension tables (attempting to model shared or conformed dimensions).

Data that can't be related

Most relational connection types are completely supported. Cubes, SAP HANA (with OLAP attribute), JSON, and Google Analytics are limited to a single logical table in Tableau 2020.2. Stored procedures can only be used within a single logical table.

Published data sources can't be related to each other. You also can't edit published data sources.

Unsupported

  • Cube databases do not support the new logical layer. Connecting to a cube offers the same experience as pre-2020.2.
  • Stored Procedures: Don't support federation, relationships, or joins. They are represented in a single logical table, and don't allow opening the Join/Union canvas (physical layer).
  • Splunk: Doesn't support left joins (and therefore relating logical tables).
  • JSON: Doesn't support federation, custom SQL, joins, or relationships (only unions).
  • Datasources that do not support LOD calcs. For more information, see Data Source Constraints for Level of Detail Expressions.

Limited support

  • Salesforce and WDC Standard Connections: These are represented as joined tables within a logical table. Adding these connections is currently only supported for single, logical table data sources. Standard connections cannot join to an existing table.
  • SAP HANA: Doesn't currently support relating logical tables when the connection has the OLAP attribute set.

Create and define relationships

After you drag the first table to the top-level canvas of the data source, each new table that you drag to the canvas must be related to an existing table. When you create relationships between tables in the logical layer, you are building the data model for your data source.

Note: You can't edit the data model of a published data source.

Create a relationship

You create relationships in the logical layer of the data source. This is the default view of the canvas that you see in the Data Source page.

  1. Drag a table to the canvas.

  2. Drag another table to the canvas. When you see the 'noodle' between the two tables, drop that table.

    The Edit Relationship dialog box opens. Tableau automatically attempts to create the relationship based on existing key constraints and matching fields to define the relationship. If it can't determine the matching fields, you will need to select them.

    To change the fields: Select a field pair, and then click in the list of fields below to select a new pair of matching fields.

    To add multiple field pairs: After you select the first pair, click Close, and then click Add more fields.

    Note: In Tableau 2020.3 and later, you can create relationships based on calculated fields, and compare fields used for relationships using operators in the relationship definition. Note that the following connectors do not support inequality operators: Google BigQuery, MapR, Salesforce.

    If no constraints are detected, a Many-to-many relationship is created and referential integrity is set to Some records match. These default settings are a safe choice and provide the most a lot of flexibility for your data source. The default settings support full outer joins and optimize queries by aggregating table data before forming joins during analysis. All column and row data from each table becomes available for analysis.

    In many analytical scenarios, using the default settings for a relationship will give you all of the data you need for analysis. Using a many-to-many relationship will work even if your data is actually many-to-one or one-to-one. If you know the particular cardinality and referential integrity of your data, you can adjust the Performance Options settings(Link opens in a new window) to describe your data more accurately and optimize how Tableau queries the database.

  3. Add more tables following the same steps, as needed.

After you have built your multi-table, related data source, you can dive into exploring that data. For more information, see How Analysis Works for Multi-table Data Sources that Use Relationships and Troubleshooting multi-table analysis.

Move a table to create a different relationship

To move a table, drag it next to a different table. Or, hover over a table, click the arrow, and then select Move.

Tip: Drag a table over the top of another table to replace it.

Remove a table from a relationship

To move a table, hover over a table, click the arrow, and then select Remove.

View a relationship

  • Hover over the relationship line (noodle) to see the matching fields that define it. You can also hover over any logical table to see what it contains.

Edit a relationship

  • Click a relationship line to open the Edit Relationship dialog box. You can add, change, or remove the fields used to define the relationship. Add additional field pairs to create a compound relationship.
    To add multiple field pairs: After you select the first pair, click Close, and then click Add more fields.

Tips on creating relationships

  • The first table that you drag to the canvas becomes the root table for the data model in your data source. After you drag out the root table, you can drag out additional tables in any order. You will need to consider which tables should be related to each other, and the matching field pairs that you define for each relationship.
  • Before you start creating relationships, viewing the data from the data source before or during analysis can be useful to give you a sense of the scope of each table. For more information, see View Underlying Data. You can also use View Data to see a table's underlying data when a relationship is invalid.
  • If you are creating a star schema, it can be helpful to drag the fact table out first, and then relate dimension tables to that table.
  • Each relationship must be made of at least one matched pair of fields. Add multiple field pairs to create a compound relationship. Matched pairs must have the same data type. Changing the data type in the Data Source page does not change this requirement. Tableau will still use the data type in the underlying database for queries.
  • Relationships can be based on calculated fields. You can also specify how fields should be compared by using operators when you define the relationship.
  • Deleting a table in the canvas automatically deletes its related descendants as well. If you delete the root table, all other tables in the model are also removed.

Validate relationships in your data source

You have several options for validating your data model for analysis. As you create the model for your data source, we recommend going to the sheet, selecting that data source, and then building a viz to explore record counts, unmatched values, nulls, or repeated measure values. Try working with fields across different tables to ensure everything looks how you expect it to.

What to look for:

  • Are your relationships in the data model using the correct matching fields for their tables?
  • What are the results of dragging different dimensions and measures into the view?
  • Are you seeing the expected number of rows?
  • Would compound relationships make the relationship more accurate?
  • If you changed any of the Performance Options settings from the default settings, are the values that you are seeing in the viz what you would expect? If they aren't, you might want to check the settings, or reset to the default.

Options for validating relationships and the data model:

  • Every table includes a count of its records, as a field named TableName(Count), at the level of detail for that table. To see the count for a table, drag its Count field into the view. To see the count for all tables, select the Count field for each table in the Data pane, and then click the Text Table in Show Me.
  • Click View Data in the Data pane to see the number of rows and data per table. Also, before you start creating relationships, viewing the data from the data source before or during analysis can be useful to give you a sense of the scope of each table. For more information, see View Underlying Data.
  • Drag dimensions onto rows to see the Number of Rows in the status bar. To see unmatched values, click the Analysis menu, and then select Table Layout > Show Empty Rows or Show Empty Columns. You can also drag different measures to the view, such as <YourTable>(Count) from one of the tables represented in your viz. This ensures that you will see all values of the dimensions from that table.

Excel For Mac Create Relationship Between Tables Pdf

Tip: If you would like to see the queries that are being generated for relationships, you can use the Performance Recorder in Tableau Desktop.

  1. Click the Help menu, and then select Settings and Performance > Start Performance Recording.
  2. Drag fields into the view to build your viz.
  3. Click the Help menu, and then select Settings and Performance > Stop Performance Recording.
  4. In the Performance Summary dashboard, under Events Sorted By Time, click an 'Executing Query' bar and view the query below.

Another more advanced option is to use the Tableau Log Viewer(Link opens in a new window) on GitHub. You can filter on a specific keyword using end-protocol.query. For more information, start with the Tableau Log Viewer wiki page(Link opens in a new window) in GitHub.

Dimension-only visualizations

When using a multi-table data source with related tables: If you build a dimension-only viz, Tableau uses inner joins and you won't see the full unmatched domain.

To see partial combinations of dimension values, you have can:

  • Use Show Empty Rows/Columns to see all of the possible rows. Click the Analysis menu, and then select Table Layout > Show Empty Rows or Show Empty Columns.
  • Add a measure to the view, such as <YourTable>(Count) from one of the tables represented in your viz. This ensures that you will see all values of the dimensions from that table.

For more information, see How Analysis Works for Multi-table Data Sources that Use Relationships and Troubleshooting multi-table analysis.

Relationships (logical tables) versus joins (physical tables)

While similar, joins and relationships behave differently in Tableau, and are defined in different layers of the data model. You create relationships between logical tables at the top-level, logical layer of your data source. You create joins between physical tables in the physical layer of your data source.

Joins merge data from two tables into a single table before your analysis begins. Merging the tables together can cause data to be duplicated or filtered from one or both tables; it can also cause NULL rows to be added to your data if you use a left, right, or full outer join. When doing analysis over joined data, you need to make sure that you correctly handle the effects of the join on your data.

Note: When duplication or the filtering effects of a join might be desirable, use joins to merge tables together instead of relationships. Double-click a logical table to open the physical layer and add joined tables.

A relationship describes how two independent tables relate to each other but does not merge the tables together. This avoids the data duplication and filtering issues that might occur in a join and can make working with your data easier.

relationshipsjoins
Defined between logical tables in the Relationship canvas (logical layer)Defined between physical tables in the Join/Union canvas (physical layer)
Don't require you to define a join type Require join planning and join type
Act like containers for tables that are joined or unionedAre merged into their logical table
Only data relevant to the viz is queried. Cardinality and referential integrity settings can be adjusted to optimize queries.Run as part of every query
Level of detail is at the aggregate for the vizLevel of detail is at the row level for the single table
Join types are automatically formed by Tableau based on the context of analysis. Tableau determines the necessary joins based on the measures and dimensions in the viz.Join types are static and fixed in the data source, regardless of analytical context. Joins and unions are established prior to analysis and don’t change.
Rows are not duplicatedMerged table data can result in duplication
Unmatched records are included in aggregates, unless explicitly excludedUnmatched records are omitted from the merged data
Create independent domains at multiple levels of detailSupport scenarios that require a single table of data, such as extract filters and aggregation

Relationships versus blends

While both relationships and blends support analysis at different levels of detail, they have distinct differences. One reason you might use blends over relationships is to combine published data sources for your analysis.

relationshipsblends
Defined in the data sourceDefined in the worksheet between a primary and a secondary data source
Can be publishedCan't be published
All tables are equal semanticallyDepend on selection of primary and secondary data sources, and how those data sources are structured.
Support full outer joinsOnly support left joins
Computed locallyComputed as part of the SQL query
Related fields are fixedRelated fields vary by sheet (can be customized on a sheet-by-sheet basis)

Excel For Mac Create Relationship Between Tables Excel

Features of different options for combining data: Relationships, joins, and blends

There are many ways to combine data tables, each with their own preferred scenarios and nuances.

Relate

Use when combining data from different levels of detail.

  • Requires matching fields between two logical tables. Multiple matching field pairs can define the relationship.
  • Automatically uses correct aggregations and contextual joins based on how fields are related and used in the viz.
  • Supports many-to-many and outer joins.
  • Relationships are consistent for the entire workbook and can be published.
  • Can be published, but you can't relate published data source, or edit relationships in published data sources.
  • Can't define relationships based on calculated fields or geographic fields.
  • Using data source filters limits join culling benefits of relationships.
Join

Use when you want to add more columns of data across the same row structure.

  • Requires common fields between two physical tables.
  • Requires establishing a join clause and a join type.
  • Can join on a calculation.
  • Joined physical tables are merged into a single logical table with a fixed combination of data.
  • May cause data loss if fields or values are not present in all tables (dependent on join types used).
  • May cause data duplication if fields are at different levels of detail.
  • Can use data source filters.
Union

Use when you want to add more rows of data with the same column structure.

  • Based on matching columns between two tables.
  • Unioned physical tables are merged into a single logical table with a fixed combination of data.
Blend

Use when combining data from different levels of detail.

  • Can be used to combine published data sources, but can't be published.
  • Can be used between a relational data source and a cube data source.
  • Data sources can be blended on a per-sheet basis.
  • Are always effectively left joins (may lose data from secondary data sources).

Other articles in this section

Thanks for your feedback!