What are relationships in excel

Have you ever used VLOOKUP to bring a column from one table into another table? Now that Excel has a built-in Data Model, VLOOKUP is obsolete. You can create a relationship between two tables of data, based on matching data in each table. Then you can create Power View sheets and build PivotTables and other reports with fields from each table, even when the tables are from different sources. For example, if you have customer sales data, you might want to import and relate time intelligence data to analyze sales patterns by year and month.

All the tables in a workbook are listed in the PivotTable and Power View Fields lists.

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

When you import related tables from a relational database, Excel can often create those relationships in the Data Model it’s building behind the scenes. For all other cases, you’ll need to create relationships manually.

  1. Make sure the workbook contains at least two tables, and that each table has a column that can be mapped to a column in another table.

  2. Do one of the following: Format the data as a table, or Import external data as a table in a new worksheet.

  3. Give each table a meaningful name: In Table Tools, click Design > Table Name > enter a name.

  4. Verify the column in one of the tables has unique data values with no duplicates. Excel can only create the relationship if one column contains unique values.

    For example, to relate customer sales with time intelligence, both tables must include dates in the same format (for example, 1/1/2012), and at least one table (time intelligence) lists each date just once within the column.

  5. Click Data > Relationships.

If Relationships is grayed out, your workbook contains only one table.

  1. In the Manage Relationships box, click New.

  2. In the Create Relationship box, click the arrow for Table, and select a table from the list. In a one-to-many relationship, this table should be on the many side. Using our customer and time intelligence example, you would choose the customer sales table first, because many sales are likely to occur on any given day.

  3. For Column (Foreign), select the column that contains the data that is related to Related Column (Primary). For example, if you had a date column in both tables, you would choose that column now.

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

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

  6. Click OK.

More about relationships between tables in Excel

  • Notes about relationships

  • Example: Relating time intelligence data to airline flight data

  • “Relationships between tables may be needed”

    • Step 1: Determine which tables to specify in the relationship

    • Step 2: Find columns that can be used to create a path from one table to the next

Notes about relationships

  • You’ll know whether a relationship exists when you drag fields from different tables onto the PivotTable Fields list. If you aren’t prompted to create a relationship, Excel already has the relationship information it needs to relate the data.

  • Creating relationships is similar to using VLOOKUPs: you need columns containing matching data so that Excel can cross-reference rows in one table with those of another table. In the time intelligence example, the Customer table would need to have date values that also exist in a time intelligence table.

  • In a data model, table relationships can be one-to-one (each passenger has one boarding pass) or one-to-many (each flight has many passengers), but not many-to-many. Many-to-many relationships result in circular dependency errors, such as “A circular dependency was detected.” This error will occur if you make a direct connection between two tables that are many-to-many, or indirect connections (a chain of table relationships that are one-to-many within each relationship, but many-to-many when viewed end to end. Read more about Relationships between tables in a Data Model.

  • The data types in the two columns must be compatible. See Data types in Excel Data Models for details.

  • Other ways to create relationships might be more intuitive, especially if you are not sure which columns to use. See Create a relationship in Diagram View in Power Pivot.

Example: Relating time intelligence data to airline flight data

You can learn about both table relationships and time intelligence using free data on the Microsoft Azure Marketplace. Some of these datasets are very large, requiring a fast internet connection to complete the data download in a reasonable period of time.

  1. Start Power Pivot in Microsoft Excel add-in and open the Power Pivot window.

  2. Click Get External Data > From Data Service > From Microsoft Azure Marketplace. The Microsoft Azure Marketplace home page opens in the Table Import Wizard.

  3. Under Price, click Free.

  4. Under Category, click Science & Statistics.

  5. Find DateStream and click Subscribe.

  6. Enter your Microsoft account and click Sign in. A preview of the data should appear in the window.

  7. Scroll to the bottom and click Select Query.

  8. Click Next.

  9. Choose BasicCalendarUS and then click Finish to import the data. Over a fast internet connection, import should take about a minute. When finished, you should see a status report of 73,414 rows transferred. Click Close.

  10. Click Get External Data > From Data Service > From Microsoft Azure Marketplace to import a second dataset.

  11. Under Type, click Data.

  12. Under Price, click Free.

  13. Find US Air Carrier Flight Delays and click Select.

  14. Scroll to the bottom and click Select Query.

  15. Click Next.

  16. Click Finish to import the data. Over a fast internet connection, this can take 15 minutes to import. When finished, you should see a status report of 2,427,284 rows transferred. Click Close. You should now have two tables in the data model. To relate them, we’ll need compatible columns in each table.

  17. Notice that the DateKey in BasicCalendarUS is in the format 1/1/2012 12:00:00 AM. The On_Time_Performance table also has a datetime column, FlightDate, whose values are specified in the same format: 1/1/2012 12:00:00 AM. The two columns contain matching data, of the same data type, and at least one of the columns (DateKey) contains only unique values. In the next several steps, you’ll use these columns to relate the tables.

  18. In the Power Pivot window, click PivotTable to create a PivotTable in a new or existing worksheet.

  19. In the Field List, expand On_Time_Performance and click ArrDelayMinutes to add it to the Values area. In the PivotTable, you should see the total amount of time flights were delayed, as measured in minutes.

  20. Expand BasicCalendarUS and click MonthInCalendar to add it to the Rows area.

  21. Notice that the PivotTable now lists months, but the sum total of minutes is the same for every month. Repeating, identical values indicate a relationship is needed.

  22. In the Field List, in “Relationships between tables may be needed”, click Create.

  23. In Related Table, select On_Time_Performance and in Related Column (Primary) choose FlightDate.

  24. In Table, select BasicCalendarUS and in Column (Foreign) choose DateKey. Click OK to create the relationship.

  25. Notice that the sum of minutes delayed now varies for each month.

  26. In BasicCalendarUS and drag YearKey to the Rows area, above MonthInCalendar.

You can now slice arrival delays by year and month, or other values in the calendar.

Tips:  By default, months are listed in alphabetical order. Using the Power Pivot add-in, you can change the sort so that months appear in chronological order.

  1. Make sure that the BasicCalendarUS table is open in the Power Pivot window.

  2. On the Home table, click Sort by Column.

  3. In Sort, choose MonthInCalendar

  4. In By, choose MonthOfYear.

The PivotTable now sorts each month-year combination (October 2011, November 2011) by the month number within a year (10, 11). Changing the sort order is easy because the DateStream feed provides all of the necessary columns to make this scenario work. If you’re using a different time intelligence table, your step will be different.

“Relationships between tables may be needed”

As you add fields to a PivotTable, you’ll be informed if a table relationship is required to make sense of the fields you selected in the PivotTable.

Create button appears when relationship is needed

Although Excel can tell you when a relationship is needed, it can’t tell you which tables and columns to use, or whether a table relationship is even possible. Try following these steps to get the answers you need.

Step 1: Determine which tables to specify in the relationship

If your model contains just a few tables, it might be immediately obvious which ones you need to use. But for larger models, you could probably use some help. One approach is to use Diagram View in the Power Pivot add-in. Diagram View provides a visual representation of all the tables in the Data Model. Using Diagram View, you can quickly determine which tables are separate from the rest of the model.

Diagram view showing disconnected tables

Note:  It’s possible to create ambiguous relationships that are invalid when used in a PivotTable or Power View report. Suppose all of your tables are related in some way to other tables in the model, but when you try to combine fields from different tables, you get the “Relationships between tables may be needed” message. The most likely cause is that you’ve run into a many-to-many relationship. If you follow the chain of table relationships that connect to the tables you want to use, you will probably discover that you have two or more one-to-many table relationships. There is no easy workaround that works for every situation, but you might try creating calculated columns to consolidate the columns you want to use into one table.

Step 2: Find columns that can be used to create a path from one table to the next

After you’ve identified which table is disconnected from the rest of the model, review its columns to determine whether another column, elsewhere in the model, contains matching values.

For example, suppose you have a model that contains product sales by territory, and that you subsequently import demographic data to find out if there is correlation between sales and demographic trends in each territory. Because the demographic data comes from a different data source, its tables are initially isolated from the rest of the model. To integrate the demographic data with the rest of your model, you’ll need to find a column in one of the demographic tables that corresponds to one you’re already using. For example if the demographic data is organized by region, and your sales data specifies which region the sale occurred, you could relate the two datasets by finding a common column, such as a State, Zip code, or Region, to provide the lookup.

Besides matching values, there are a few additional requirements for creating a relationship:

  • Data values in the lookup column must be unique. In other words, the column can’t contain duplicates. In a Data Model, nulls and empty strings are equivalent to a blank, which is a distinct data value. This means that you can’t have multiple nulls in the lookup column.

  • Data types of both the source column and lookup column must be compatible. For more information about data types, see Data types in Data Models.

To learn more about table relationships, see Relationships between tables in a Data Model.

Top of Page

Excel is not a database for sure; however, people tend to use it as a database. Since primary versions of Excel, people keep on using it for making the connection between different tables with the help of VLOOKUP, INDEX, MATCH, SUMIF, etc.

Making reports was never an easier task as handling larger datasets is a tricky thing. Excel Data Model is a true blessing that lets you save time using automatic data reports. Here we will talk about how to create a relationship in Excel. Using the Data Model, you can make the connection between two tables and a figure of the relationship in a pivot table side by side.

To understand how to create a relationship between two tables in Excel, let’s start with a quick overview of the relationship.

What is a Relationship?

Merging two different tables result in a relationship:

  • Within two tables, you must find a mutual column. However, you don’t need to allocate the same name to the columns. 
  • The new column must have distinctive entries only. 

Hundreds of tables exist in relational databases that make such kinds of relationships. In Excel, you can make a fundamental relational structure using the Data Model option. Suppose an Order data table and a Sales data table, both contain a mutual column State. And both tables have duplicate data in these columns, so you are not allowed to add that column to the new table. You have to skip the State column.

Why Is It Important to Make a Relationship? 

Realizing the importance of anything helps you understand why you should use it. Just a single data table is not enough to provide all the information needed to make a report. It often happens in many cases, that’s why the need of creating relationship tables in Excel comes up. 

Taking the above example, making a report about a person who marked the order is not likely to be placed in the Sales data table. Making a relationship between two tables Order and Sales just need the Order ID to extract the name from the table to be used in the Sales report.

Note: Remember that PivotTables replace the term “column” with “field.” 

The Fundamental Needs

Before understanding how to create a relationship in Excel, let’s understand the basics of this process. For this, you must have Power Pivot and Power Query to complete the process of making an Excel Data Model. 

Below you will find out the starting procedure:

How to Get Power Pivot 

For Excel 2010, the Power Pivot add-in is needed to be downloaded from Microsoft. Once the downloading is complete, make sure to install it properly on your system. 

For Excel 2013, you don’t need to download or install anything manually as the Office Pro Plus edition of Excel 2013 has a built-in Power Pivot. You just need to activate it before using it. 

To activate the Power Pivot follow the steps given below: 

  • Open the Excel workbook and click the Ribbon on the File. 
  • Click on the Options and you will see a window of Excel Options. 
  • Next, click on Add-ins.
  • On the Manage box, click the drop-down menu and choose COM Add-ins. 
  • Press Go and choose the checkbox for Microsoft Power Pivot for Excel.

How to Get Power Query (Get & Transform) 

  • For Excel 2010, similar to the Power Pivot add-in, you need to download the Power Query add-in from Microsoft. 
  • Once the downloading is complete, you need to install it properly and you will start seeing the Power Query on the Ribbon.  
  • For Excel 2013, again you don’t need to download and install anything as there is a built-in Power Query. You just have to activate it by following the same steps you did to make Power Pivot functional in Excel 2013. 
  • For Excel 2016 and Later, you have to go to the Data tab on Excel Ribbon to get the Power Query (Get & Transform). 

How to Create a Relationship in Excel – Step-by-Step Guide

  • At first, you need to set your data as tables. In the process of making a table, you have to select a random cell in the range and press Ctrl + T. From the design tab, you have to spell out a name for the table. 
  • Next, you have to open the data ribbon & click on the relationships button. 
  • To make a new relationship, you have to click on the New. 
  • Choose Source table & column name. To mark the table and column name, you need to record it. It does not matter what order you are using for making this relationship table. You should never underestimate the power of Excel no matter what.  

  • Now, you can add more relationships as required.

Things to Consider About Relationship

Keep in mind that VLOOKUPS and making relationships both are alike somehow. Duplicate data columns are needed for Excel to cross-reference rows of one table to the other.

While using relationships, you must keep in mind that there must be similar data types in both columns. For instance, connecting columns of both tables must have the same data type.

Excel 2013 holds up one to one or one to many relationships only. It simply shows that one of the tables is free from duplicate values on the linking columns. For instance, the products table must not contain similar product IDs.  

Slicing these Pivot Tables is easier just the way you can do with normal Pivot Tables. For instance, you can further slice the products report on the products prices.

Do You Like Using Relationships?

Well, the relationships feature has replaced many tools and things. People skipped VLOOKUP for most of their analysis. Now, relationships features have become the central part of Excel, which is being used more and more.

You should try using relationship tables and data models in Excel. Elaborate your thoughts about using relationship tables and data models with us. I hope that you got an idea about how to create a relationship in Excel. Now, try it, share it and practice it.

Have you ever been in a VLOOKUP hell?

Its what happens when you have to write a lot of vlookup formulas before you can start analyzing your data. Every day, millions of analysts and managers enter VLOOKUP hell and suffer. They connect table 1 with table 2 so that all the data needed for making that pivot report is on one place. If you are one of those, then you are going to love Excel’s data model & relationships feature.

Table relationships & Data model feature of Excel - cartoon

In simple words, this feature helps you connect one set of data with another set of data so that you can create combined pivot reports.

Practical Example – V(X)LOOKUP hell vs. Data Model heaven

Lets say you are looking sales data for your company. You have transaction data like below.

Example data

And you want to find out how many units you are selling by product category and customer’s gender.

Unfortunately, you only have product ID & customer ID.

With VLOOKUP Hell,

  1. You first fetch all the customer and product data and place them in separate ranges.
  2. Then write a vlookup formula to fetch product category, another to fetch customer gender.
  3. Then fill down the formulas for entire list of transactions.
  4. Now make a pivot table.

Assuming you have 30,000 transactions, you have to write 60,000 VLOOKUP formulas to create this one report!!!

With Data Model heaven,

  1. Create relationships between Sales, Products & Customer tables
  2. Create a pivot table

Creating a relationship in Excel – Step by Step tutorial

  1. Relationship feature in Excel 2013 data ribbon tabFirst set up your data as tables. To create a table, select any cell in range and press CTRL+T. Specify a name for your table from design tab. Read introduction to Excel tables to understand more.
  2. Now, go to data ribbon & click on relationships button.
  3. Click New to create a new relationship.
  4. Select Source table & column name. Map it to target table & column name. It does not matter which order you use here. Excel is smart enough to adjust the relationship.
    Creating a new relationship in Excel 2013 - how to?
  5. Add more relationships as needed.

Using relationships in Pivot reports & analysis

  1. Select any table and insert a pivot table (Insert > Pivot table, more on Pivot tables).
  2. Make sure you check the “Add this data to data model” check box.
    Adding a pivot table with data model in Excel 2013
  3. In your pivot table field list, check “ALL” instead of “ACTIVE” to see all table names.
  4. Select fields from various tables to create a combined pivot report or pivot chart

Example: Category & Gender Sales Report

  1. Add category to row labels
  2. Add gender to column labels
  3. Add quantity to values
  4. and your report is ready!

Example Pivot report made with Excel data model

Things to keep in mind when you using relationships

  • Same data types in both columns: Columns that you are connecting in both tables should have same data type (ie both numbers or dates or text etc.)
  • One to one or One to many relationships only: Excel 2013 supports only one to many or one to one relationships. That means one of the tables must have no duplicate values on the column you are linking to. (for example products table should not have duplicate product IDs).
  • You can add slicers too: You can slice these pivot tables on any field you want (just like normal pivot tables). For example, you can further slice the above report on customer’s profession or product’s SKU size.

Benefits of Data Model based Pivot Tables

Once you have a data model in spreadsheet, you will enjoy several benefits (apart from multi-table pivots that is). They are,

  • Distinct counts: This simple but often tricky to calculate number is easy to get once you have data model based pivot. Just go to value field settings and change the summary type to “Distinct count”. Here is a tip explaining how to get distinct counts in Excel pivots.
  • Measures & DAX: Once you have a Data Model, you can unleash the full Power Pivot features on your workbook. You can create measures (using DAX language) and calculate things that are otherwise impossible with regular Excel. Here is an example of percentage of something calculation with DAX & Data Model, to get started.
  • Pivots from data in other files & databases: You can combine data model with the abilities of Power Query to create pivots from data in other places. For example, you can make a pivot from sales data in SAP with customer data in CRM system. Here is an overview of what is Power Query?
  • Pivots from more than 1mn rows of data: You can connect to very large datasets and make pivots from them with the help of data model. Here is a demo of how to set up data model for 1+mn rows of data.
  • Convert Pivot Tables to formulas: Once you have a data model based pivot table, you can turn it in to a set of formulas. You can access this feature from “Analyze” ribbon. This will replace your pivot with a bunch of CUBE formulas. Here is an overview of CUBE formulas.

Drawbacks of Data Model:

Of course, its not all cup cakes and coffee with Data Model. There are a few drawbacks of data model based pivot tables.

  • Compatibility: Data model & relationship feature is available only in Excel 2013 or above. This means, you cannot create or share such pivot reports with people using older versions of Excel.
  • Not able to group data: In regular Pivot Tables, you can group numeric, data or text fields. But with data model pivot tables, you can no longer group data. You must create another table with the group mapping and use it as a relationship.

Download Example File

Click here to download Excel data model demo file. It contains 3 different tables and a combined pivot report (with slicer) to show you what is possible.

Do you use relationships?

Ever since discovering PowerPivot, I kind of stopped using VLOOKUP (or XLOOKUP) for most of my own analysis. Now that relationships are part of main Excel functionality, I am using them even more.

What about you? Are you using relationships & data model in Excel? What cool things are you doing with it? Share your tips with us using comments.

Want even more? Try PowerPivot

If you want even more out of your reports, then try PowerPivot. It is a new feature in Excel 2013 (available as add-in in Excel 2010) that can let you do lots of powerful analysis on massive amounts of data. Here is an introduction to PowerPivot.


Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.




  • 41 Comments




  • Ask a question or say something…




  • Tagged under

    data model, downloads, excel 2013, Learn Excel, pivot tables, relationship, vlookup




  • Category:

    Excel Howtos, Pivot Tables & Charts

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my story • FREE Excel tips book

Advanced Excel & Dashboards training - Excel School is here

Excel School made me great at work.

5/5

Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It’s all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

Related Tips

41 Responses to “How to use Excel Data Model & Relationships”

  1. Ashish Youngy says:

    Data is Excel 2013 behaves so much like a OLAP cube when using with PivotTables. And this is actually wow. Consider learning not just DAX but MDX too 🙂 Happy Excel

    @Chandoo.. Have a nice and safe time in US. Best Wishes. And when they are publishing your interview in Entrepreneur 🙂

  2. Buzz says:

    I have been using PowerPivot in Excel 2010. My understanding was (via PowerPivot Pro blog) that Power Pivot would NOT be available in Excel 2013 in all versions; my recollection is that it was only going to be available in certain enterprise subscription editions. Thus, for individual users, it will no longer be available? For that reason I have moved some of my projects to Tableau, and do not expect to upgrade to Excel 2013.
    Can you confirm the availability of Power Pivot for all Excel 2013 users , or will it be restricted and unavailable for some users?

      • This is something that Excel is doing very poorly: letting people know what’s available with what. It also doesn’t help that they have so many packages and versions.

        Excel Professional Plus has Power Pivot and Power View. I went through this last week. Spent 4 days upgrading from 365 Home Premium ($99 for the 1-yr subscription) to an additional $7/month for Professional Plus.

        Also, one page on Microsoft’s site says that their Sharepoint Online Package 2 has Power View. NO! It’s not true. Sharepoint Online Package 2 will INTERACT with a spreadsheet that has PP or PV, Package 1 will not.

  3. Just this weekend I upgraded from Home Premium to Professional Plus and spent time with Power View and PowerPivot.

    Up to that point I never saw myself in VLOOKUP Hell, and it may not be going away any time soon. I’m surprised to discover how many of my clients are still on Excel 2003. And then I have Mac users who don’t have a lot of this great stuff available to them at all.

    These are great features and I’m going to dive into the Data Models. Unfortunately, I suspect, for me, the practical use may be limited to blogposts because I can’t teach Power View in my workshops or send a client a spreadsheet that has a Power View in it.

    • thundom says:

      Hi OZ,

      I think the Microsoft would only upgrade the excel to a certain level instead of making it so powerful that it might threat their BI product. You know these «powerful» stuff can be easily done with a entry level crystal reports version.

      Glad to listen to ur opinion on it.

      I spent quite some time and energy on Excel and used it a lot, but now I am focusing energy on BI software like crystal reports.

    • thundom says:

      We both know that based on the technology today. All the time we spend on the Macro and advanced function of Excel can be done easily with other softwares which costs only hundreds of bucks.

      • @Thondom
        I don’t think Excel tries to be the solver of all problems
        It is a generic tool
        Which for about 95% of people will do what they want 95% of the time
        There will always be specifics where specific custom software will do better than Excel
        It is the commonness of Excel which means that I can send a model to you and it will work , most of the time, that is its strength, of course combined with its flexility in being able to be adapted to suit most needs

        • thundom says:

          Hi Hui,
          You are right.

          But,

          for the business and individual, who spend too much resource on Excel to meet their BI requirements and other processing requests.

          Should they open their eyes to other ways to do it, in this age? Especially for many people try too much time to process stuff with thousands lines of macro programming.

          It is just as when human being created gun fire, the martial arts would not be that effective.

          Ppl need to be prodent when they choose their solution.

          • Hi guys, I just came across your conversation. I have an example of BI vs. Excel stuff. Here in Russia there is an ERP-system called «1C». It became a defacto standart for accounting, planning and BI / analytics. It is positioned as a flexible and powerful system and it really is.
            But its reporting abilities aren’t user-friendly (or maybe just not me-friendly).
            Many reports require programming and all those SQL things, so that is common for a company to have a couple of programmers who develop and code those reports.
            So the common solution is to export data to Excel and then process it to be more suitable for further analysis or reporting.
            Well, it’s obviously not a rule of thumb that special BI software can outperform Excel in day-to-day routine.

  4. Tris says:

    Hi Chandoo, thanks for publishing great Excel information. Pardon the ignorance as I havent used Data Model nor PowerPivot. But having seen your video clip on PowerPivot, how does Data Model differ from PowerPivot — the «process» seems familiar? Have a great day! And Excel to new heights! Regards,

    • @Tris, one main difference is that Data Model is part of Excel Home Premium. You’ve got to upgrade to ProPlus to get PowerPivot and Power View.

  5. Nolberto says:

    Excellent posting, some pride themselves for having sheets with thousands of formulas or complicated formulas, but in the end the important thing is to work as little as possible.

    • @Nolberto let’s not gloat yet. Some people are forced to have thousands of complicated formulas when they don’t have the fancy tools. I’m sad for the 2003 users who have to use SUMPRODUCT when the rest of us have SUMIFS available.

      In the end, I think the important thing is clean, trustworthy data—however you arrive at it. People survived more than 300 years with slide rules and paper. No PowerPivot for the Wright Brothers.

  6. koi says:

    hi chandoo,

    i added 2 column into sales, 1st column vlookup customer ID to CUST sheet to get the male or female, then 2nd column vlookup Product ID to Product sheet to get the product name, then after that i make pivot table out of sales sheet.

    but then the result is really different from yours

    the purposes is just try to do the vlookup vs add to data model to see if they get same result

    thanks

    • Hi Koi,

      We are using gender vs. category in the report. Can you try with that? I am sure the results will match.

  7. koi says:

    ups sorry, didnt see that you’re filtering using slicer..then it is good now the result are same with less effort 🙂

    thanks

  8. SPrasad says:

    Hi Chandoo, .I am interested to know whether we can build a star schema or snow flake data models through relations in Excel? (trying to correlate with Qlikview)

    • Hi there,

      You can create a Star schema for sure. Snow-flake is possible too. As long as all relationships are one to many (or one to one) anything is possible.

      • Nestavaro says:

        What if customer.profession change its value after sometime?
        Supposed we have monthly data for Sales. What if one customer is a doctor in Feb, then a pilot in October, for example?

        How to build data model for such that situation?

        Thank you.

  9. […] Introduction to Excel 2013 Data Model & Relationships […]

  10. Raghavendra Shanbog says:

    Hello ,
    I find this option similar to that of MS Access.
    In MS Access as well we have relationship concept and once you create a relationship, you can start creating number of queries based on that.
    But MS Access is not so user friendly and basically its database. Good that we are getting those options/functions in Excel.
    Thanks for sharing this info.

    Regards,
    Raghavendra Shanbog

  11. What is star schema and snow flake.??? Can we have next article on that if it is useful for us???

  12. Roberto says:

    Hi there, can anyone help? I tried testing this out in Excel using two tables. When I go to the Data tab the Relationships button does not appear at all. I am using Microsoft version 14.0.4760.1000, Microsoft Office Professional Plus 2010. Does this version have this capability? Or is there an add-in required?

  13. […] even a layperson can perform if they have the almighty Excel 2010 and PowerPivot installed. Or Excel 2013′s Data Model, which lets you mash up data from Excel Tables and serve them up directly as PivotTables with not a […]

  14. Chandeep Chhabra says:

    Chandoo/Hui,

    The dates grouping feature does not seem to work in Data Model. Is that true or am I making a mistake somewhere?

  15. Jay says:

    I don’t think this is really for «lookups»…

    Try creating a pivot with sale ID and customer name in row fields. It will give you ALL customer names per sale ID.

    You’d need to use RELATED function in a new column in powerpivot if you want something equivalent to «vlookup»

  16. Aslam says:

    Please explain the difference between data model and power pivot, the functions of both of them are different and similar
    thanks

  17. […] Handling large volumes of data in Excel—Since Excel 2013, the “Data Model” feature in Excel has provided support for larger volumes of data than the 1M row limit per worksheet. Data Model also embraces the Tables, Columns, Relationships representation as first-class objects, as well as delivering pre-built commonly used business scenarios like year-over-year growth or working with organizational hierarchies. For several customers, the headroom Data Model is sufficient for dealing with their own large data volumes. In addition to the product documentation, several of our MVPs have provided great content on Power Pivot and the Data Model. Here are a couple of articles from Rob Collie and Chandoo. […]

  18. Bernadette Savage says:

    I need to use a slicer to allow a user to select vendor by name. In the background, I need to obtain the vendor ID to link to multiple datasets where the name may not be spelled consistently. Any advice?

  19. Andrea says:

    I’ve tried this in Excel 2016. It works great.
    I can even create Cube Formulas on the Data model after I’ve inserted the pivot table.
    Just for the fun of it, I tried to see if I could do Cube Formulas without creating the pivot table in advance. I can define Cube members, but it seems as if the measure part is playing tricks on me.

    I can’t get a Cube Value for Chocolates sold to Male customers.
    With the Pivot created the formula looks like this (and works fine)
    =CUBEVALUE(«ThisWorkbookDataModel»;»[Customer].[Gender].&[Male]»;»[Product].[Category].&[Chocolates]»;»[Measures].[Sum of Quantity]»)

    Does anyone know how I can solve this, or am I asking the impossible?

  20. Kwabena Anaafi says:

    I want to see the video on this topic

  21. nestavaro says:

    What if customer.profession change its value after sometime?
    Supposed we have monthly data for Sales. What if one customer is a doctor in Feb, then a pilot in October, for example?

    How to build data model for such that situation?

    Thank you.

    • In such case, you need to make relationships based on two columns. This kind of feature is not supported in Excel. You can use Power Query to merge tables based on multiple columns and return a consolidated giant table to Excel for reporting.

  22. nestavaro says:

    Is it able in MS Access?
    I have never used access before.

  23. faisal says:

    thanks chandooo your article is very helpfull for troubling peoples’ especially in office environment under boss pressure.

  24. Ron says:

    Here is an introduction to PowerPivot.

    The link above is broken

  25. Venkatesh says:

    Hi. This has really taken my interest.. I have huge data tables to work with…and I use vlookup to fetch certain data. I have different data in different sheets…

    Like customer sales (customer code, product code,qty, piece rate, total amount, branch code) data in one sheet
    Branch details in another (branch code, branch address, state , region)
    Customer Geographical Data in third sheet (region, region name)
    Product details in fourth sheet (product code, product description and related)

    Now I use a vlookup to get branch name, state and product name respectively into my main sheet.

    Now what I want is

    customer code, product code,qty, piece rate, total amount, branch code) data in one sheet, branch address, state , region, region name, product description

    Can’t his be done thru data model… I tried but it’s not working… Eitherway, I will gonthru thr session on e again and give a try… Any help, is appreciated. Thankyou

  26. Achyutanand Khuntia says:

    Dear All,

    i am striving to do reverse relationship in Power pivot ,

    example : —

    1 — Data sheet
    2. — Source data

    step to stops — import first data sheet in power piovt and then source data , made relationship with both sheet , after created relationship i am able to do put related formula in source data sheet only (=releted(‘Source data'[Amount]), if i go to put formula in data sheet , parameter of Source data are not visible ,

    could someone educate me how can i do , and utilize related formula in data sheet.

Leave a Reply

Download PC Repair Tool to quickly find & fix Windows errors automatically

In Microsoft Excel, you can create relationships between two tables based on the matching data within the table, even when the tables are from different sources. In older versions of Excel, people have used functions such as VLOOKUP, INDEX, and MATCH to create relationships between tables, but in newer versions of Excel, there is a Relationship command that you can use to create relationships between tables in Excel easily.

How to create relationships between tables in Excel

Follow the steps below to create relationships between tables in Excel.

Naming the Tables

  • When creating a relationship between tables, the tables must be related.
  • Now we are going to name both tables.
  • Select the table you want to give a name to and click the Table Design tab.
  • On the Table Design tab, type a name for the table in the Table Name box in the Properties group. Do the same for the other table.

Creating Relationships between tables

Now we will create the relationship between tables after naming the tables.

On the Data tab, click Relationships in the Data Tools group.

A Manage Relationships dialog box will open.

In the Manage Relationship dialog box, click the New button.

In the Create Relationship dialog box, click the drop-down arrow for the table and select a table from the list.

Now click the drop-down arrow for the Related Table and choose the related table from the list.

In the Column (Foreign) list box, select the column that is related in both tables, for example, Customer ID.

In the Related Column (Primary), select the column Customer ID because it is in both tables.

Then click OK.

Then click Close.

Using the Pivot table as a lookup

Open a new worksheet.

Select a cell, for example, cell A1.

Click the Insert tab, and click the Pivot Table button.

Now select the option From Data Model.

A PivotTable from Data Model dialog box will open.

Click the option Existing Worksheet, then click OK.

The PivotTable Fields pane will appear on the right.

Click the drop-down arrow of the table you want to use in the lookup. In this tutorial, we have selected the Customer ID field from the Order table.

We will check the check box for the Customer ID field and drag it to the Rows area in the pane.

Try to drag fields from both tables into the Rows Area.

If the table includes a price, cost, or total, drag it into the Values area.

The results will appear on the left.

We hope you have understood how to create relationships between tables in Excel.

Which key creates relationship between two tables?

When it comes to the Foreign key in Microsoft Excel, it helps to determine the relationship between tables. The Foreign key helps to connect multiple tables in a database or Excel spreadsheet. The Foreign key is to be a column that is in both tables.

What are table relationships?

A table relationship connects tables and matches data in both tables. Relationships use key fields, which are fields with the same name and data in both tables. In Microsoft Excel, the Foreign key is the primary key that lets users match data in both tables.

READ: How to add Bullets to Text Box in Excel.

Ezoic

Shantel has studied Data Operations, Records Management, and Computer Information Systems. She is quite proficient in using Office software. Her goal is to become a Database Administrator or a System Administrator.

Ever had multiple related tables and wondering how to create a report that connects them together in a single Pivot Table? We have just the thing with Data Model and Relationships!

This is our data that we will use. What we want to do is create a report that shows the First Name of the student and the Number of Classes that the student has taken.

The tricky part here is the First Name is in the Students Table, while the number of classes can be retrieved from the Classes Table. Both tables are linked by the StudentId column.

Data Model and Relationships

STEP 1: Select the Classes Table. Go to Insert > Pivot Table > New Worksheet 

Make sure to tick Add this data to the Data Model. Click OK.

Data Model and Relationships

STEP 2: Select the Students Table. Go to Insert > Pivot Table > New Worksheet 

Make sure to tick Add this data to the Data Model. Click OK.

Data Model and Relationships

STEP 3: Click All in PivotTable Fields and you should see both tables there.

Data Model and Relationships

STEP 4: Now we need to link them together! Go to PivotTable Tools > Analyze > Calculations > Relationships

Data Model and Relationships

Click New.

Data Model and Relationships

STEP 5: There are 2 sides of a relationship when we want to link them together.

The rule of thumb, is the primary table should have no duplicates. This is the Students table as it does not have duplicate Student Ids.

Set the following then Click OK.

Table – Classes

Column – StudentId

Related Table – Students

Related Column – StudentId

Data Model and Relationships

Click Close.

Data Model and Relationships

STEP 6: In the ROWS section put in the Students(FirstName) field.  In the VALUES section put in the Classes (ClassName) field.

With just that, you can see that Excel was able to show the results in a merged fashion! You can see Daisy has 2 classes enrolled. And from the individual tables, you would not have that information readily available!

Data Model and Relationships

How to Use the Data Model in Excel Pivot Tables

Helpful Resource:

Data Model and Relationships

About The Author

Bryan

Bryan

Bryan is a best-selling book author of the 101 Excel Series paperback books.

Excel isn’t a database, but that hasn’t stopped people from using it as one.

People have been doing this since early versions of Excel and creating relationships between different tables using VLOOKUP or INDEX and MATCH.

The good news is that more and more database-like functionality is being added with each version, and since Excel 2013 we’ve been able to add relationships to tables.

This example has an Orders table that contains data related to customer orders such as the Customer ID, Product Sold, and the Total.

Another table called Customers has the Name and Country for each Customer ID. But what do you do if you want to analyze the Orders data by customer Name or Country?

One solution would be to add two more columns to the Orders data and use a VLOOKUP function to bring in the customer Name and Country based on the Customer ID.

Another more elegant solution would be to use the pivot table Data Model to create a Relationship between the Orders table and the Customers table using the Customer ID field in both tables.

Create a table based on the Orders table.

Go to the Insert tab in the ribbon and select Pivot Table from the Tables section.

From the Create PivotTable menu.

  1. Select your Orders Table.
  2. Check the Add this data to the Data Model box.
  3. Press the Ok button.

Repeat these steps for the Customers table.

With either of your pivot tables created, you should see both tables in the PivotTable Fields window from the All view.

You can delete one of the pivot tables created since you only need one, the data will remain in the Data Model.

Build your pivot table with the Name from the Customers table in the Rows area and Total from the Orders table in the Values area.

  1. Drag the Name field from the Customers table to the Rows area. Expand the table to see fields by clicking the arrow next to the table name.
  2. Drag the Total field from the Orders table to the Values area.
  3. A notice will appear above the field list saying Relationships between tables may be needed. From here you can select Auto-Detect and let Excel guess the relationships between your tables or you can Create them yourself.

If you choose Auto-Detect, Excel will work to create the relationships and you can check the results by pressing the Manage Relationships button or just Close the window.

With this simple relationship, Excel is easily able to create the relationship. Small tables and consistent field names between tables will help Auto-Detect to work.

If you choose to Create the relationships yourself then the Create Relationship menu will open.

  1. Select the Orders table as the main Table.
  2. Select Customer ID as the Column (Foreign).
  3. Select the Customers table as the Related Table.
  4. Select Customer ID as the Related Column (Primary).
  5. Press the OK button to finish creating the relationship.

Now your resulting pivot table contains the customer Name from the Customers table along with the correct corresponding Total from the Orders table.

You can also create these relationships before trying to build the pivot table. You can do this from either the Data tab or the Analyze tab in the ribbon.

  • Find the Relationships button in the Data tab under the Data Tools section.
  • Find the Relationships button in the Analyze tab under the Calculations section.

This will open the Manage Relationships dialog box.

  1. Here you can see the existing relationships and select them to Edit, Activate, Deactivate or Delete.
  2. Create any new relationships using the New button.

This is an awesome way to avoid VLOOKUP or INDEX and MATCH, and minimize the columns in your tables.

About the Author

John MacDougall

John is a Microsoft MVP and qualified actuary with over 15 years of experience. He has worked in a variety of industries, including insurance, ad tech, and most recently Power Platform consulting. He is a keen problem solver and has a passion for using technology to make businesses more efficient.

3 minute read

Have you ever been in a VLOOKUP hell?

Its what happens when you have to write a lot of vlookup formulas before you can start analyzing your data. Every day, millions of analysts and managers enter VLOOKUP hell and suffer. They connect table 1 with table 2 so that all the data needed for making that pivot report is on one place. If you are one of those, then you are going to love Excel’s data model & relationships feature.

In simple words, this feature helps you connect one set of data with another set of data so that you can create combined pivot reports.

VLOOKUP hell vs. Data Model Heaven

Lets say you are looking sales data for your company. You have transaction data like below.

data-model-img

And you want to find out how many units you are selling by product category and customer’s gender.

Unfortunately, you only have product ID & customer ID.

With VLOOKUP Hell

  1. You first fetch all the customer and product data and place them in separate ranges.
  2. Then write a vlookup formula to fetch product category, another to fetch customer gender.
  3. Then fill down the formulas for entire list of transactions.
  4. Now make a pivot table.

Assuming you have 30,000 transactions, you have to write 60,000 VLOOKUP formulas to create this one report.

With Data Model heaven

  1. Create relationships between Sales, Products & Customer tables
  2. Create a pivot table

Creating a relationship in the Data Model

  1. First set up your data as tables. To create a table, select any cell in range and press CTRL+T. Specify a name for your table from design tab.
  2. Now, go to data ribbon & click on relationships button.
  3. Click New to create a new relationship.
  4. Select Source table & column name. Map it to target table & column name. It does not matter which order you use here. Excel is smart enough to adjust the relationship.
  5. Add more relationships as needed.

data-model-img

Using relationships in Pivot reports & analysis

  1. Select any table and insert a pivot table (Insert > Pivot table).
  2. Make sure you check the “Add this data to data model” check box.
  3. In your pivot table field list, check “ALL” instead of “ACTIVE” to see all table names.
  4. Select fields from various tables to create a combined pivot report or pivot chart

data-model-img

Example: Category and Area Sales Report

  1. Add Category to rows labels
  2. Add Area to columns labels
  3. Add Quantity to values
  4. and your report is ready!

data-model-img

Excel Recognises a Relationship Between Tables may be Needed

In the demo file, the example pivot table is a Category and Area Sales Report, however when I added the fields to the pivot table, Excel recognised that I hadn’t yet made a relationship

data-model-img
data-model-img
data-model-img

Things to Keep in Mind When Using Relationships

  • Same data types in both columns: Columns that you are connecting in both tables should have same data type (ie both numbers or dates or text etc.)
  • One to one or One to many relationships only: Excel 2013 supports only one to many or one to one relationships. That means one of the tables must have no duplicate values on the column you are linking to. (for example products table should not have duplicate product IDs).
  • You can add slicers too: You can slice these pivot tables on any field you want (just like normal pivot tables). For example, you can further slice the above report on customer’s profession or product’s SKU size.

Download Example File

Click here to download the example file: data-model-example.xlsx. It contains 3 different tables and a combined pivot report and a slicer to show you what is possible.

Excel directly doesn’t provide us ready to use a database, but we can create one using relationships between various tables. This type of relationship helps us identify the interconnections between the table and helps us whenever a large number of datasets are connected in multiple worksheets. We can look for or easily find out certain information very quickly. 

Create Relational Tables in Excel

We will create two tables: one is the Master table and the other one is the detail table. The master table will have information like customer_id, product, sales channel, and cost. It will act as a primary table and rarely it will undergo a change. The detail table will have information like customer_id, name, and country. Data in the child table (detail table) changes frequently. We will create a relationship between two tables using the common column – customer_id in both fields.

Table 1: Order table: We create an order table with fields customer_id, Product, sales channel, and Cost. 

Order-Table.

Table 2: Customer table: We create a customer table with fields customer_id, Name, and country. 

Customer-Table.

Create both tables in excel either in the same sheet or as a separate file.

Method 1: By Creating a Pivot Table

Step 1: Go to the insert tab at the top of the ribbon and then Select PivotTable.

Selecting-PivotTable.

Step 2: “Create pivot table” dialog box appears. Here select the orders table in the first selection. (Here we have selected the range in our datasheet). Make sure to check the “add this data to the data model” field and then click OK.

Creating-PivotTable

Step 3: Do the same process for the customer table. Visualize the pivot table fields and go to “All view”. Both tables will be displayed. Here we have selected from the ranges so range name (range 2, range 3 in our case) will be displayed.

all-view

Step 4: To build a pivot table, select the name from the Customers table. Place it in the Rows area. We can either check the mark by expanding the table or dragging the field to the rows area. Select cost from the Orders table. Place it in the Values area.

pivot-table-fields

Step 5: Pivot the table fields pane showing the notice that “Relationship between the tables is needed”. There are two options available:

  • We can create the relationship between tables.
  • Let the excel guess by clicking on “Auto Detect”.

clicking-auto-detect

Step 6: In Auto Detect, excel will create a relationship. Click on “manage relationship” to check. By clicking on “Auto Detect,” simple associations with smaller tables and consistent field names may be built automatically. Once done, click on the close button.

selecting-manage-relationships

Step 7: The pivot table so created will have the customer name from the customer’s table and the total cost from the orders table.

pivot-table

If we want to create a relationship by ourselves, without letting excel do the auto-creation, click on the create button in the pivot table fields.

Step 8: It will open the edit relationship menu. Select the table containing orders as the main Table. (“range” in our case). Select Customer_id for the Column (Foreign). Select the table containing Customers as the Related Table. (“range1” in our case). Select Customer_id as the Related Column (Primary). Click ok to finish the relationship creation.

edit-relationship

The pivot table so created will have the customer name from the customer’s table and the total cost from the orders table.

pivot-table

Method 2: By Creating a Relationship between Two Tables

Before creating a pivot table, we can create a relationship between two tables as shown:

Step 1: Go to the Data tab on the top of the ribbon and then to the data tools group. Click on the relationships button.

selecting-data-tab

Step 2: This will open the relationships manage dialog box. All the existing relationships will be displayed with “active” status. We can perform all the options viz. edit, activate, deactivate, delete, auto-detect, etc.  

manage-relationships

Step 3: Once done, click on close. This will create a table having a similar customer_id from both tables. It will display the customer’s name from the customer’s table and the total cost from the orders table.

table-created

Advantages of Relational Tables

  • Aids in working with a large amount of data.
  • Recognize relations among multiple tables.
  • Helps in quickly searching data.
  • Retrieve specific information easily and quickly.
  • View the same data set in multiple ways.
  • Reduce data errors and redundancy.

Excel is a powerful tool for data analysis and subsequent automation when handling large sets of data. You could be spending significant time analyzing tons of data using VLOOKUP, INDEX-MATCH, SUMIF, etc.

Thanks to the Excel Data Model, you can save precious time through automatic data reports. Find out how easily you can assign a relationship between two tables by using the Data Model and an illustration of such a relationship in a pivot table in the following section.

The Basic Requirements

You’ll need Power Pivot and Power Query (Get & Transform) to accomplish several tasks while creating Excel Data Model. Here is how you can get these features in your Excel workbook:

How to Get Power Pivot

1. Excel 2010: You’ll need to download the Power Pivot add-in from Microsoft and then install it for your Excel program on your computer.

2. Excel 2013: Office Professional Plus edition of Excel 2013 includes Power Pivot. But, you need to activate it before first use. Here is how:

  1. Click on File on the Ribbon of an Excel workbook.
  2. Then click on Options to open Excel Options.
  3. Now, click on Add-ins.
  4. Select COM Add-ins by clicking on the drop-down menu of the Manage box.
  5. Click on Go and then select the checkbox for Microsoft Power Pivot for Excel.

Excel 2013 activate Power Pivot

3. Excel 2016 and Later: You’ll find the Power Pivot menu on the Ribbon.

How to Get Power Query (Get & Transform)

1. Excel 2010: You can download the Power Query add-in from Microsoft. After installation, Power Query will show up on the Ribbon.

2. Excel 2013: You need to activate Power Query by following the same steps that you just did to make Power Pivot functional in Excel 2013.

3. Excel 2016 and Later: You can find Power Query (Get & Transform) by going to the Data tab on Excel Ribbon.

Create Data Model by Importing Data to the Excel Workbook

For this tutorial, you can get pre-formatted sample data from Microsoft:

Download: Sample student data (data only) | Sample student data (complete model)

You can import a database with multiple related tables from many sources like Excel workbooks, Microsoft Access, websites, SQL Server, etc. Then you need to format the data set so that Excel can utilize it. Here are the steps that you can try:

1. In Excel 2016 and later editions, click on the Data tab and select New Query.

2. You will find several ways to import data from external or internal sources. Choose the one that suits you.

import data from external or internal sources

3. If using Excel 2013 edition, click on Power Query on the Ribbon and then select Get External Data to choose data for import.

4. You will see the Navigator box where you need to choose which tables you need to import. Click on the check box for Select multiple items to pick several tables for import.

Select multiple items to pick several tables

5. Click on Load to complete the import process.

6. Excel will create a Data Model for you using these tables. You can see the table column headers in the PivotTable Fields listings.

table column headers in the PivotTable Fields listings

You can also utilize Power Pivot functions like calculated columns, KPIs, hierarchies, calculated fields, and filtered datasets from Excel Data Model. For this purpose, you’ll need to generate Data Model from a single table. You can try these steps:

1. Format your data in a tabular model by selecting all of the cells containing data and then click Ctrl+T.

2. Now, select the entire table and then click on the Power Pivot tab on the Ribbon.

3. From the Tables section, click on Add to Data Model.

click on Add to Data Model

Excel will create table relationships between related data from the Data Model. For this, there should be primary and foreign key relationships within the imported tables.

Excel utilizes the relationship information from the imported table as a foundation to generate connections between the tables in a Data Model.

Build Relationships Between the Tables in the Data Model

Now that you have a Data Model in your Excel workbook, you’ll need to define relationships between the tables to create meaningful reports. You need to assign a unique field identifier or primary key to each table, like Semester ID, Class Number, Student ID, etc.

The Diagram View feature of Power Pivot will let you drag and drop those fields to build a relationship. Follow these steps to create table links in Excel Data Model:

1. On the Ribbon of the Excel workbook, click on the Power Pivot menu.

2. Now, click on Manage in the Data Model section. You’ll see the Power Pivot editor as shown below:

the Power Pivot editor

3. Click on the Diagram View button located in the View section of the Power Pivot Home tab. You’ll see table column headers grouped according to the table name.

column headers grouped

4. You’ll now be able to drag and drop the unique field identifier from one table to another. Following is the relationship schematic between the four tables of the Excel Data Model:

relationship schematic between the four tables

The following describes the linkage between tables:

  • Table Students | Student ID to table Grades | Student ID
  • Table Semesters | Semester ID to table Grades | Semester
  • Table Classes | Class Number to table Grades | Class ID

5. You can create relationships by choosing a pair of unique value columns. If there are any duplicates, you’ll see the following error:

you’ll see the following error

6. You’ll notice Star (*) on one side and One (1) on the other in the Diagram View of relationships. It defines that a one-to-many relationship exists between the tables.

7. On the Power Pivot editor, click on the Design tab and then select Manage Relationships to know which fields make the connections.

Manage Relationships in Excel Data Model

Generate a PivotTable Using the Excel Data Model

You can now create a PivotTable or PivotChart to visualize your data from Excel Data Model. An Excel workbook may contain only one Data Model, but you can keep updating the tables.

Because data changes over time, you can continue to use the same model and save time when working with the same data set. You’ll notice more time savings when working on data in thousands of rows and columns. To create a PivotTable based report, follow these steps:

1. On the Power Pivot editor, click on the Home tab.

2. On the Ribbon, click on PivotTable.

3. Choose any one between New Worksheet or Existing Worksheet.

On the Ribbon, click on PivotTable

4. Select OK. Excel will add a PivotTable that will show the Field List pane on the right.

Following is a holistic view of a pivot table created by utilizing the Excel Data Model for the sample student data used in this tutorial. You can also create professional pivot tables or charts from big data using the Excel Data Model tool.

Following is a holistic view of a pivot table

Transform Complex Data Sets Into Simple Reports Using Excel’s Data Model

Excel Data model utilizes the benefits of creating relationships between tables to produce meaningful pivot tables or charts for data reporting purposes.

You can continuously update the existing workbook and publish reports on updated data. You don’t have to edit formulas or invest time in scrolling through thousands of columns and rows each time the source data updates.

What is the Data Model in Excel?

The data model in Excel is a type of data table where two or more two tables are in a relationship with each other through a common or more data series. In the data model, tables and data from various other sheets or sources come together to form a unique table that can access the data from all the tables.

For example, a data table containing tables of customers, product items, and product sellers. We can use the Excel data model to connect this dataset and create a relationship between them.

Table of contents
  • What is the Data Model in Excel?
    • Explanation
    • Examples
      • Example #1
      • Example #2
    • Things to Remember
    • Recommended Articles

Explanation

  • It allows integrating data from multiple tables by creating relationships based on a common column.
  • Data models are used transparently, providing tabular data that can be used in a Pivot Table in ExcelA Pivot Table is an Excel tool that allows you to extract data in a preferred format (dashboard/reports) from large data sets contained within a worksheet. It can summarize, sort, group, and reorganize data, as well as execute other complex calculations on it.read more and Pivot Charts in excelIn Excel, a pivot chart is a built-in feature that allows you to summarize selected rows and columns of data in a spreadsheet. It is a visual representation of a pivot table that helps in the summarization and analysis of datasets, patterns, and trends.read more. In addition, it integrates the tables, enabling extensive analysis using pivot tables, power pivot, and Power View in ExcelExcel Power View is a data visualization technology that helps you create interactive visuals like graphs, charts. It allows you to analyze data by looking at the visuals you created. As a result, it makes your excel data more meaningful and insightful for better decision making.read more.
  • The data model allows loading data into Excel’s memory.
  • It is saved in memory, where we cannot directly see it. Then We can instruct Excel to relate data to each other using a common column. The ‘Model’ part of the data model refers to how all tables relate.
  • The data model can access all the information it needs, even in multiple tables. After the data model is created, Excel has the data available in its memory. With the data in its memory, we can access the data in many ways.

Data Model in Excel

You are free to use this image on your website, templates, etc, Please provide us with an attribution linkArticle Link to be Hyperlinked
For eg:
Source: Data Model in Excel (wallstreetmojo.com)

Examples

You can download this Data Model Excel Template here – Data Model Excel Template

Example #1

We have three datasets related to the salesperson: the first contains revenue information, the second includes the salesperson’s income and the third consists of the expenses of the salesperson.

Data Model Example 1

To connect these three datasets and make a relationship with them, we make a data model with the following steps:

  • Convert the datasets to table objects:

We cannot create a relationship with ordinary datasets. The data model works with only Excel TablesIn excel, tables are a range with data in rows and columns, and they expand when new data is inserted in the range in any new row or column in the table. To use a table, click on the table and select the data range.read more objects. To do this:

  • Step 1 – We must first click anywhere inside the dataset, click on the “Insert” tab, and click on “Table” in the “Tables” group.

Data Model Example 1-1

  • Step 2 – Check or uncheck the ‘My table has headers’ option and click “OK.”

Data Model Example 1-2

  • Step 3 – We must enter the table’s name in the “Table Name” in the “Tools” group with the new table selected.

Data Model Example 1-3

  • Step 4 – Now, we can see that the first dataset is converted to a “Table” object. On repeating these steps for the other two datasets, we know that they also get converted to “Table” objects as below:

Data Model Example 1-4

Adding the “Table” objects to the Data Model: Via Connections or Relationships.

Via Connections

  • We must select one table, click on the “Data” tab, and click on “Connections.”

Model Via Connections Example 1-5

  • There is an icon for “Add.” Expand the dropdown of “Add” and click on “Add to the Data Model” in the resulting dialog box.

Model Via Connections Example 1-6

  • Click on “Tables” in the resulting dialog box, select one of the tables, and click “Open.”

Model Via Connections Example 1-7

In doing this, it would create a workbook data model with one table, and a dialog box would appear as follows:

Model Via Connections Example 1-8

So if we repeat these steps for the other two tables, the data model will contain all three tables.

Model Via Connections Example 1-9

We can now see that all three tables appear in the “Workbook Connections.”

Via Relationships

Create the relationship: Once both the datasets are table objects, we can create a relationship between them. To do this:

  • First, we should click on the “Data” tab and “Relationships.”

Model Via Relationships Example 1-10

  • As a result, we can see an empty dialog box with no current connections.

Model Via Relationships Example 1-11

  • Then, click on “New,” and another dialog box appears.

Model Via Relationships Example 1-12

  • Expand the “Table” and “Related Table” dropdowns: the “Create Relationship” dialog box appears to pick the tables and columns to use for a relationship. In the expansion of “Tables,” we must select the dataset we wish to analyze somehow, and in “Related Table,” we must choose the dataset with LOOKUP values.
  • The lookup table in excelLookup tables are simply named tables that are used in combination with the VLOOKUP function to find any data in a large data set. We can select the table and name it, and then type the table’s name instead of the reference to look up the value.read more is the smaller table in the case of one to many relationships. It contains no repeated values in the common column. In expanding “Column (Foreign),” we must select the common column in the main table. In “Related Column (Primary),” we must choose the common column in the related table.

Model Via Relationships Example 1-13

  • With all these four settings selected, click on “OK.” A dialog box appears as follows on clicking on “OK.”

Model Via Relationships Example 1-14

If we repeat these steps to relate the other two tables: the “Revenue” Table with “Expenses” table, then they also get connected in the data model as follows:

Data Model Example 1-15

Excel now creates the relationship behind the scenes by combining data in the data model based on a common column: Salesperson ID (in this case).

Example #2

Now, in the above example, we wish to create a PivotTable that evaluates or analyzes the table objects:

  1. We must first click on “Insert” -> “PivotTable.”

    Data Model Example 2

  2. We need to click on the “Use an external data source” option in the resulting dialog box and click on “Choose Connection.”

    Data Model Example 2-1

  3. Then, we must click on “Tables” in the resulting dialog box, select the “Workbook Data Model” containing three tables, and click “Open.”

    Data Model Example 2-2

  4. Select the “New Worksheet” option in the location and click on “OK.”

    Data Model Example 2-3

  5. Consequently, the “PivotTable Fields” pane will display table objects.

    Data Model Example 2-4

    Data Model Example 2-4
    Now we can make changes in the PivotTable accordingly to analyze the table objects as required.

  6. For instance, in this case, if we wish to find the total revenue or revenue for a particular salesperson, then a PivotTable is created as follows:

    Data Model Example 2-5

    Data Model Example 2-6
    It is an immense help in the case of a model/table containing a large number of observations.

So, we can see that the pivot table instantly uses the data model (picking it by choosing connection) in Excel memory to show relationships between tables.

Things to Remember

  • We can analyze data from several tables at once using the data model.
  • By creating relationships with the data model, we surpass the need for using VLOOKUPThe VLOOKUP excel function searches for a particular value and returns a corresponding match based on a unique identifier. A unique identifier is uniquely associated with all the records of the database. For instance, employee ID, student roll number, customer contact number, seller email address, etc., are unique identifiers.
    read more
    , SUMIF, INDEX functionThe INDEX function in Excel helps extract the value of a cell, which is within a specified array (range) and, at the intersection of the stated row and column numbers.read more, and MATCH formulas as we do not need to get all columns within a single table.
  • Models are implicitly created when datasets are imported in Excel from outside sources.
  • We can create table relationships automatically if we import related tables with primary and foreign key relationships.
  • While creating relationships, the columns that we are connecting in tables should have the same data type.
  • With the pivot tables created with the data model, we can add slicers and slice them on any field at pivot tables we want.
  • The advantage of the Data Model over LOOKUP() functionsThe LOOKUP excel function searches a value in a range (single row or single column) and returns a corresponding match from the same position of another range (single row or single column). The corresponding match is a piece of information associated with the value being searched.
    read more
    is that it requires substantially less memory.
  • Excel 2013 supports only one-to-one or one to many relationships, i.e., one of the tables must have no duplicate values on the column we are linking to.

Recommended Articles

This article is a guide to Data Model in Excel. We discuss creating a data model from Excel tables using connections and relationships, practical examples, and a downloadable Excel template. You may learn more about Excel from the following articles: –

  • Excel Value Formula
  • Excel MATCH Formula
  • Share an Excel Workbook
  • Consolidate Data in Excel

Понравилась статья? Поделить с друзьями:
  • What are pivot tables used for in excel
  • What are paragraph styles in word
  • What are one word syllables
  • What are named ranges in excel
  • What are microsoft word styles