Sdílet prostřednictvím


Create a Relationship Between Two Tables

If the tables in your data source do not have existing relationships, or if you add new tables, you can use the tools in PowerPivot for Excel to create new relationships. For information about how relationships are used in PowerPivot for Excel, see Relationships Overview.

Note

In Windows Vista and Windows 7, features in the PowerPivot window are available on a ribbon, which is discussed in this topic. In Windows XP, features are available from a set of menus. If you are using Windows XP and want to see how the menu commands relate to the ribbon commands, see The PowerPivot UI in Windows XP.

To create a relationship between two tables

  1. In the PowerPivot window, click the Design tab, and in the Relationships group, click Create Relationship.

  2. In the Create Relationship dialog box, click the down arrow for Table, and select a table from the dropdown list.

    In a "one-to-many" relationship, this table should be on the "many" side.

  3. For Column, select the column that contains the data that is related to Related Lookup Column.

  4. For Related Lookup Table, select a table that has at least one column of data that is related to the table you just selected for Table.

    In a "one-to-many" relationship, this table should be on the "one" side, meaning that the values in the selected column do not contain duplicates. If you attempt to create the relationship in the wrong order (one-to-many instead of many-to-one), an icon will appear next to the Related Lookup Column field. Reverse the order to create a valid relationship.

  5. For Related Lookup Column, select a column that has unique values that match the values in the column you selected for Column.

  6. Click Create.

Considerations for Creating Relationships

When creating a relationship, consider the following:

  • There can be only one relationship between each pair of tables.

  • The data values in Related Lookup Column must be unique. In other words, the column cannot contain duplicates.

  • Each table must have a single column that uniquely identifies each row in that table.

  • The data types in Column and Related Lookup Column must be compatible. For more information about data types, see Data Types Supported in PowerPivot Workbooks.

For a complete list of requirements, see "Requirements for Relationships" in Relationships Overview.