Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Many-to-Many Relationships: How to Set Them Up

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

A many-to-many relationship in Excel means linking two lists where each item on one side can connect to several items on the other - for example, students and the classes they take, or products and the orders that contain them. Excel has no built-in many-to-many feature in a normal spreadsheet, but you can model it cleanly using a "bridge" (junction) table of pairs, and if you want real relationship handling, the Power Pivot data model supports it. The steps below cover both approaches; the bridge-table method works in every Excel version.

What You'll Need

  • Excel 2016 or later on desktop is recommended (the bridge-table method works in older versions and in Excel for the web; the Power Pivot steps in this guide are for Windows desktop, where the Power Pivot tab is available)
  • Two lists of items, each with a unique identifier (ID) column - for example a Students table and a Classes table
  • Your data formatted as Excel Tables (select the range and press Ctrl+T)

Step-by-Step

Menu and button labels can differ slightly between Excel versions and platforms; the steps below use current Windows desktop wording.

Method 1: Bridge table (works everywhere)

  1. Create your two main tables: one for each side of the relationship (e.g., Students with StudentID and Name; Classes with ClassID and ClassName). Format each as a table with Ctrl+T and give each a clear name in Table Design > Table Name.
  2. Create a third table, the bridge (also called a junction or mapping table), with two columns: StudentID and ClassID. Format it as a table and name it something like Enrollments.
  3. Add one row to the bridge table for each pairing. A student in three classes gets three rows; a class with twenty students appears in twenty rows. Each row represents exactly one link.
  4. Optionally add extra columns to the bridge table for details that belong to the link itself, such as Grade or EnrollmentDate - these belong on the pair, not on the student or the class.
  5. To look up all matches from one side, use FILTER. FILTER is available in Microsoft 365 and Excel 2021; in older versions, use a pivot table built from the bridge table instead.
  6. To build the reverse view (all classes for one student), repeat step 5 with the conditions swapped.
  7. Prevent duplicates: select the two ID columns in the bridge table, then use Data > Data Validation (Custom) with a formula such as =COUNTIFS($A$2:$A$500,A2,$B$2:$B$500,B2)=1 so the same pair cannot be entered twice.
  8. Optionally add dropdowns so people pick IDs instead of typing them: select the StudentID column in the bridge table, open Data > Data Validation, choose List, and point the source at the Students table's ID column. Repeat for ClassID.
  9. Summarize with a pivot table: click inside the bridge table, go to Insert > PivotTable, drag ClassID to Rows and StudentID to Values (set to Count) to see how many students are in each class.

Method 2: Power Pivot data model (Windows desktop)

  1. If you don't see a Power Pivot tab, enable it via File > Options > Add-ins: at the bottom choose COM Add-ins and click Go, then tick Microsoft Power Pivot for Excel and click OK. This add-in is included with certain editions such as Microsoft 365 and Excel 2016+ standalone; if it isn't listed, use Method 1.
  2. Click inside each of your three tables and, from the Power Pivot tab, choose Add to Data Model for each one.
  3. Open Power Pivot > Diagram View. Drag from Students[StudentID] to Enrollments[StudentID], and from Classes[ClassID] to Enrollments[ClassID], to create two one-to-many relationships through the bridge table. Never try to connect Students directly to Classes - the model only allows one-to-many links, which is exactly why the bridge table exists.
  4. Close the Power Pivot window, then insert a pivot table via Insert > PivotTable and tick Add this data to the Data Model (or use Power Pivot > PivotTable) so the pivot can use fields from all three tables.
  5. Build your report: drag ClassName from the Classes table to Rows and StudentID from the Students table to Values. Because the relationships run through the bridge table, Excel counts students per class correctly, even though the two tables aren't directly related.

Common Mistakes

  • Storing multiple values in one cell ("Math, Physics, Chemistry"). This breaks lookups, filtering and pivot tables - use one row per pair in a bridge table instead.
  • Trying to create a direct relationship between the two main tables in Power Pivot. It will fail or give wrong results; the relationship must pass through the bridge table.
  • Duplicate rows in the bridge table, which double-count in pivots. Use the data validation formula from step 7.
  • Matching on names instead of IDs. Two students called "J. Smith" will silently merge; always link on a unique identifier.
  • Building formulas against fixed ranges like A2:A500 that stop covering new rows. Reference whole table columns (Enrollments[StudentID]) so the formulas grow automatically.

Tips

  • Name your tables meaningfully (Students, Classes, Enrollments) - readable formulas are far easier to maintain.
  • Keep attributes in the right table: a student's email belongs in Students, a class's room belongs in Classes, a grade belongs in the bridge table.
  • If the dataset is large or shared, consider moving the data to Power Query or a proper database later, but for most spreadsheet-sized projects the bridge table is all you need.

Troubleshooting

  • FILTER returns a #CALC! or #VALUE! error: usually no rows match your criteria. Wrap it with an if_empty argument: =FILTER(range, condition, "No matches").
  • Pivot counts look inflated: you almost certainly have duplicate pairs in the bridge table. Select the bridge table and use Data > Remove Duplicates on the two ID columns, then add the validation rule.
  • Power Pivot says a relationship can't be created: check that both key columns contain unique values on the "one" side and that no blanks exist in the key columns of the bridge table.
  • Relationships option in a regular pivot table is greyed out or fails: regular pivot tables only support one-to-many single-column matches, which is why the many-to-many case needs the bridge table plus the data model described above.
  • FILTER isn't recognised: your Excel version predates dynamic arrays. Fall back to a pivot table from the bridge table, or use a helper column with COUNTIFS to flag matching rows.
  • Data validation stops accepting new pairs: reopen Data > Data Validation and confirm the formula ranges cover all current rows, or convert the data to a table and reference table columns instead of fixed ranges.

Frequently Asked Questions

Does Excel support many-to-many relationships natively?

Not directly. The data model only supports one-to-many relationships, so a many-to-many pattern is always built as two one-to-many relationships through a bridge table. Outside Power Pivot, a plain bridge table with FILTER or pivot tables achieves the same result.

Can I do this in Excel for the web or on a Mac?

The bridge-table method works everywhere, including Excel for the web and Mac, and FILTER is supported in current versions on those platforms. The Power Pivot add-in described here is Windows desktop only.

What is a bridge table?

It's a table that stores one row per relationship pair - for example, one row per student-class enrollment. It's the standard way to represent many-to-many data in any tool, not just Excel.

How do I list all items linked to one selection?

Use FILTER on the bridge table with a condition matching your selection, for example =FILTER(Enrollments[ClassID], Enrollments[StudentID]=F1) to list every class for the student ID in F1. Add XLOOKUP to turn the IDs into names.

Why are my pivot table counts wrong?

Nearly always duplicate pairs in the bridge table, or blank/mismatched IDs (for example a number 101 in one table and text "101" in another). Clean both key columns so they hold the same data type.

Is a spreadsheet the right place for many-to-many data?

For small to medium projects, yes - a well-built bridge table is reliable. If many people edit simultaneously or the data grows large, a database or a tool like Microsoft Access or Power Query fed from a proper source is a better long-term home.