How to Create a Relationship in Excel

Last updated on November 9th, 2026 at 12:57 pm

To create a relationship in Excel, turn both sets of data into tables with Ctrl + T, then go to Data > Relationships > New. Pick the table and column that repeat values (such as Orders and CustomerID), then the related table and column where each value appears once (such as Customers and CustomerID), and select OK. You can then build one PivotTable that uses fields from both tables.

Applies to: Excel for Microsoft 365, Excel 2024, 2021, 2019, and 2016 on Windows.

What a relationship does

A relationship links two tables through a column they share, so Excel can combine them without copying data across. For example, an Orders table lists a CustomerID on each order, and a Customers table lists each customer’s name and city once. With a relationship, a PivotTable can show sales by city, even though city isn’t in the Orders table.

Can one table relate to several others?

Yes. A Customers table can relate to Orders, Invoices, and Support Tickets, each through CustomerID.

Step 1: Format both ranges as tables

  1. Click inside the first set of data and press Ctrl + T. Check My table has headers and select OK.
  2. On the Table Design tab, type a clear name in Table Name, such as Orders.
  3. Repeat for the second set of data, for example Customers.

Naming and resizing tables is explained in more detail in creating a table in Excel with multiple columns.

Step 2: Check the shared column

  • The column you link on must be in both tables, such as CustomerID. The names don’t have to match, but the values do.
  • In the lookup table (Customers), every value must be unique. Remove duplicates first if needed.
  • Both columns must be the same data type. A number stored as text in one table won’t match a number in the other.

Step 3: Create the relationship

  1. Go to Data > Relationships (in the Data Tools group).
  2. Select New.
  3. For Table, choose the table with repeating values (Orders), and for Column (Foreign), choose CustomerID.
  4. For Related Table, choose the lookup table (Customers), and for Related Column (Primary), choose CustomerID.
  5. Select OK, then Close.

Step 4: Use it in a PivotTable

  1. Go to Insert > PivotTable > From Data Model.
  2. Choose where to put it and select OK.
  3. In the PivotTable Fields pane, select All to see both tables.
  4. Drag fields from either table into Rows, Columns, and Values. For example, City from Customers into Rows and Amount from Orders into Values.

Other ways to create a relationship

  • Let Excel suggest it: If you build a PivotTable from the Data Model with fields from two unrelated tables, Excel shows Relationships between tables may be needed. Select Auto-Detect or Create.
  • Diagram view: Go to Data > Manage Data Model (Power Pivot), switch to Diagram View, and drag the column from one table onto the matching column in the other.

Can I create relationships in Excel for Mac or the web?

Data Model features, including the Relationships dialog, are most complete in Excel for Windows. If an option is missing on another version, build the relationship on a Windows PC or use a lookup formula instead.

Do relationships change my data?

No. They only tell Excel how the tables connect. Your original tables stay exactly as they are.

To clean or combine the tables before relating them, find and enable Power Query in Excel.

When you don’t need a relationship

If you only want to bring one column across, such as each customer’s city into the Orders table, a lookup formula is simpler. In Microsoft 365, use =XLOOKUP([@CustomerID],Customers[CustomerID],Customers[City]). The same approach works when you use XLOOKUP in Excel with two sheets.

If it doesn’t work

  • The Relationships button is greyed out: The workbook needs at least two tables. Check that both ranges are formatted as tables, not plain ranges.
  • Excel reports the relationship can’t be created because of duplicate values: The lookup table has repeated IDs. Remove the duplicates so each value appears only once.
  • The PivotTable shows the same number on every row: The relationship is missing or points the wrong way. Open Relationships and check which table is the lookup table.
  • Some rows show (blank): Those IDs in Orders don’t exist in Customers. Add the missing customers or fix the IDs.