How to Create a Hierarchy Between Tables Following Relationship

Abstract: Establishes hierarchical relationships between normalized Excel tables using the Data Model to enable multi-level PivotTable analysis.

Created: 2026-10-21 by

To create a hierarchy between tables in Microsoft Excel, you must first ensure your data is normalized into distinct tables with unique primary keys. Next, navigate to the Data tab and use the Manage Relationships feature under the Power Pivot or Data Model section to link these tables via foreign keys. This establishes a relational model that allows PivotTables to drill down through multiple levels of data seamlessly.

Preparing Your Data Structure

The foundation of any hierarchical relationship in Excel lies in how you structure your source data. Before attempting to link tables, you need to separate your flat data into logical entities. For instance, if you have a single sheet containing Salesperson Name, Region, Product Category, and Sales Amount, this is denormalized data. To create a true hierarchy, you should split this into at least two tables: one for Sales containing transactional details and a lookup table for Products or Regions.

Each table must contain a column that serves as a unique identifier. In the Sales table, this might be an ID column. In the related Products table, you would have a matching ProductID. These columns are critical because they act as the bridge between your datasets. Without unique values in the "one" side of the relationship (the lookup table), Excel will throw an error or fail to create the connection properly. Ensure there are no blank cells or duplicates in these key columns, as this is a common pitfall for beginners trying to establish hierarchies.

Converting Ranges to Excel Tables

Excel's data model works best with structured references rather than simple cell ranges. You should convert each of your normalized sheets into official Excel Tables. Select any cell within your data range and press Ctrl+T (or Cmd+T on Mac). A dialog box will appear asking if your table has headers; ensure this is checked if your data includes header rows. Click OK to create the table.

It is highly recommended to give each table a descriptive name. Go to the Table Design tab that appears when a table is selected, find the Table Name field in the Properties group, and rename it to something clear like TblSales or TblProducts. Naming your tables makes the subsequent steps much easier to manage, especially when you have multiple relationships defined. If you skip this step, Excel will assign generic names like Table1, which can become confusing as your model grows more complex. Proper naming also helps in debugging issues later if your PivotTable reports incorrect totals.

Creating the Relationship via Data Model

Once your tables are prepared and named, you need to tell Excel how they relate to each other. The most straightforward method is using the Data Model interface available in modern versions of Excel. Navigate to the Data tab on the Ribbon. Look for the Relationships button, which is typically located in the Get & Transform Data group or sometimes under the PivotTable group depending on your version. If you do not see this button, ensure that you have at least one table loaded into the Data Model.

Clicking Relationships opens the Manage Data Model Relationships window. Here, you will see a list of existing connections. Click New to create a new relationship. You will be prompted to select the Parent Table (the lookup table, e.g., TblProducts) and the Child Table (the fact table, e.g., TblSales). Select the corresponding Column from each table that matches (e.g., ProductID). Ensure the CARDINALITY OF RELATIONSHIP is set to One-to-Many (1:*), which is the standard for hierarchical data. The "One" side is always the lookup table, and the "Many" side is the transactional table. Finally, click OK to save the relationship.

Building the Hierarchical PivotTable

With the relationship established, you can now build a PivotTable that leverages this hierarchy. Insert a new PivotTable by going to Insert > PivotTable. Make sure to check the box that says Add this data to the Data Model. This step is crucial; without it, the PivotTable will only see one flat table and ignore your relationships. Once the PivotTable Fields pane opens, you will see all your tables listed.

To create the hierarchy, drag fields from different tables into the Rows area. For example, drag ProductName from TblProducts and then drag OrderDate from TblSales. Because of the relationship you created, Excel will automatically group the data correctly. You can also drag multiple fields from the same table to create sub-hierarchies, such as Region followed by City. This allows users to drill down from high-level summaries to granular details instantly.

If you encounter issues where numbers seem duplicated or missing, verify that the relationship direction is correct. In some advanced scenarios, you may need to adjust the cross-filter direction in the Edit Relationship settings, but for standard hierarchical reporting, One-to-Many with Single direction is sufficient. Remember that changes to the underlying data require refreshing the PivotTable to reflect the new hierarchy state.

Troubleshooting Common Issues

Even with careful setup, users often face specific hurdles when implementing table hierarchies. One frequent problem is the inability to create a relationship due to mismatched data types. If one table stores IDs as text and the other as numbers, Excel will reject the link. Ensure both columns share the exact same data type before attempting to join them. Another common issue arises when trying to add measures that span across tables. If you try to calculate a ratio involving fields from unrelated tables, the calculation will fail. Always verify that every field used in a measure belongs to a table connected directly or indirectly through your defined hierarchy.

Additionally, performance can degrade if you create overly complex hierarchies with many-to-many relationships. While Excel supports some many-to-many scenarios, they are computationally expensive. It is better to resolve many-to-many situations by introducing a junction table in your source data design. For simpler needs, consider looking into How to add values under the same group in Pivot Table? if you are struggling with grouping logic after establishing your hierarchy. Also, refer to Combine Rows in Excel Using Pivot Table if you find yourself needing to aggregate data manually before creating the relationship.

Frequently Asked Questions

Can I create a hierarchy without using the Data Model?

No, true hierarchical relationships between separate tables require the Data Model. Standard PivotTables work with flat data ranges and cannot link multiple external tables dynamically. You must enable the Data Model option when inserting the PivotTable to access relational features.

What happens if my primary key has duplicate values?

Excel will prevent you from creating the relationship or may produce inaccurate results if duplicates exist in the "One" side of the relationship. You must clean your lookup table to ensure every key value is unique before linking. Check for hidden spaces or inconsistent casing that might cause apparent duplicates.

How do I remove an existing relationship?

Go to the Data tab, click Relationships, select the connection you wish to delete from the list, and click Delete. Confirm the action in the prompt. Removing a relationship breaks the link between the tables, causing any PivotTables relying on that hierarchy to show errors or empty fields.

Why are my totals showing up incorrectly in the PivotTable?

Incorrect totals usually indicate a broken or incorrect relationship direction. Verify that the cardinality is set to One-to-Many and that the filter direction is appropriate for your analysis. Sometimes, redundant relationships can cause double-counting; review your relationship map to ensure no circular dependencies exist.

Can I use Power Query to prepare data for hierarchies?

Yes, Power Query is excellent for normalizing data before loading it into the Data Model. You can merge queries to simulate joins, but for hierarchical reporting in PivotTables, it is often better to load separate queries as tables and link them via the Data Model relationships rather than merging them into one wide table.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More