{"id":11537,"date":"2019-04-19T13:27:43","date_gmt":"2019-04-19T11:27:43","guid":{"rendered":"https:\/\/www.myexcelonline.com\/?p=11537"},"modified":"2024-02-06T15:47:53","modified_gmt":"2024-02-06T14:47:53","slug":"data-model-and-relationships-in-microsoft-excel-pivot-tables","status":"publish","type":"post","link":"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/data-model-and-relationships-in-microsoft-excel-pivot-tables\/","title":{"rendered":"Data Model and Relationships In Microsoft Excel Pivot Tables"},"content":{"rendered":"<p>Ever had multiple related tables and wondering how to create a report that connects them together in a single <a class=\"wpil_keyword_link\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/101-excel-pivot-tables\/\" target=\"_blank\" rel=\"noopener\" title=\"Pivot Table\" data-wpil-keyword-link=\"linked\">Pivot Table<\/a>? We have just the thing with <strong>Data Model<\/strong> and Relationships!<\/p>\n<p>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.<\/p>\n<p>The tricky part here is the First Name is in the\u00a0<strong>Students Table,<\/strong> while the number of classes can be retrieved from the\u00a0<strong>Classes Table<\/strong>. Both tables are linked by the\u00a0<strong>StudentId column<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Data Model and Relationships In Microsoft Excel Pivot Tables\"  class=\"aligncenter size-full wp-image-11541\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-01.jpg\" alt=\"Data Model and Relationships In Microsoft Excel Pivot Tables\" width=\"1366\" height=\"649\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-01.jpg 1366w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-01-300x143.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-01-1024x487.jpg 1024w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-01-768x365.jpg 768w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/p>\n<div class=\"after-post-box\">\n<p><iframe src=\"https:\/\/www.youtube.com\/embed\/gqAPSYrlK2Q?rel=0 \" width=\"800\" height=\"400\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><a href=\"https:\/\/www.youtube.com\/c\/MyExcelOnlinecomtutorials?sub_confirmation=1\" target=\"_blank\" rel=\"noopener noreferrer nofollow\"><img loading=\"lazy\" decoding=\"async\" class=\"alignmiddle wp-image-111468 size-full\" style=\"vertical-align: middle;\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/1.yt_.png\" alt=\"\" title=\"\"><\/a><\/p>\n<p class=\"line-two\"><a class=\"IRPP_minimalist icon-download button small\" href=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model.xlsx\" target=\"_blank\" rel=\"noopener noreferrer\" data-leadbox=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model.xlsx\" data-leadbox-id=\"147284833f72a2:12f08263ab46dc\"><span class=\"ctaText px-3 text-capitalize\">Download excel workbook<i class=\"fa fa-download\"><\/i><\/span><span class=\"postTitle px-3\">Data-Model.xlsx<\/span><\/a><\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 1:<\/strong><\/span>\u00a0Select the Classes Table. Go to<strong><em>\u00a0Insert &gt; Pivot Table &gt; New Worksheet\u00a0<\/em><\/strong><\/p>\n<p>Make sure to tick\u00a0<strong>Add this data to the Data Model. Click OK.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Data Model and Relationships In Microsoft Excel Pivot Tables\"  class=\"aligncenter size-full wp-image-11542\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-02.jpg\" alt=\"Data Model and Relationships In Microsoft Excel Pivot Tables\" width=\"1140\" height=\"902\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-02.jpg 1140w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-02-300x237.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-02-1024x810.jpg 1024w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-02-768x608.jpg 768w\" sizes=\"(max-width: 1140px) 100vw, 1140px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 2:<\/strong><\/span>\u00a0Select the Students Table. Go to<strong><em>\u00a0Insert &gt; Pivot Table &gt; New Worksheet\u00a0<\/em><\/strong><\/p>\n<p>Make sure to tick\u00a0<strong>Add this data to the Data Model. Click OK.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Data Model and Relationships In Microsoft Excel Pivot Tables\"  class=\"aligncenter size-full wp-image-11543\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-03.jpg\" alt=\"Data Model and Relationships In Microsoft Excel Pivot Tables\" width=\"1375\" height=\"841\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-03.jpg 1375w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-03-300x183.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-03-1024x626.jpg 1024w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-03-768x470.jpg 768w\" sizes=\"(max-width: 1375px) 100vw, 1375px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 3:<\/strong><\/span>\u00a0Click All in\u00a0<strong>PivotTable Fields<\/strong> and you should see both tables there.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Data Model and Relationships In Microsoft Excel Pivot Tables\"  class=\"aligncenter size-full wp-image-11544\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-04.jpg\" alt=\"Data Model and Relationships In Microsoft Excel Pivot Tables\" width=\"898\" height=\"793\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-04.jpg 898w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-04-300x265.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-04-768x678.jpg 768w\" sizes=\"(max-width: 898px) 100vw, 898px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 4:<\/strong><\/span>\u00a0Now we need to link them together! Go to\u00a0<em><strong>PivotTable Tools &gt; Analyze &gt; Calculations &gt; Relationships<\/strong><\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Data Model and Relationships In Microsoft Excel Pivot Tables\"  class=\"aligncenter size-full wp-image-11545\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-05.jpg\" alt=\"Data Model and Relationships In Microsoft Excel Pivot Tables\" width=\"683\" height=\"245\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-05.jpg 683w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-05-300x108.jpg 300w\" sizes=\"(max-width: 683px) 100vw, 683px\" \/><\/p>\n<p><strong>Click New.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Data Model and Relationships In Microsoft Excel Pivot Tables\"  class=\"aligncenter size-full wp-image-11546\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-06.jpg\" alt=\"Data Model and Relationships In Microsoft Excel Pivot Tables\" width=\"1030\" height=\"590\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-06.jpg 1030w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-06-300x172.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-06-1024x587.jpg 1024w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-06-768x440.jpg 768w\" sizes=\"(max-width: 1030px) 100vw, 1030px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 5:<\/strong><\/span>\u00a0There are 2 sides of a relationship when we want to link them together.<\/p>\n<p>The rule of thumb, is the primary table <strong>should have no duplicates<\/strong>. This is the <strong>Students table<\/strong> as it does not have duplicate\u00a0<strong>Student Ids<\/strong>.<\/p>\n<p>Set the following then Click OK.<\/p>\n<p>Table &#8211;\u00a0<strong>Classes<\/strong><\/p>\n<p>Column &#8211;<strong> StudentId<\/strong><\/p>\n<p>Related Table &#8211; <strong>Students<\/strong><\/p>\n<p>Related Column &#8211; <strong>StudentId<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Data Model and Relationships In Microsoft Excel Pivot Tables\"  class=\"aligncenter size-full wp-image-11547\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-07.jpg\" alt=\"Data Model and Relationships In Microsoft Excel Pivot Tables\" width=\"910\" height=\"318\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-07.jpg 910w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-07-300x105.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-07-768x268.jpg 768w\" sizes=\"(max-width: 910px) 100vw, 910px\" \/><\/p>\n<p><strong>Click Close.<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Data Model and Relationships In Microsoft Excel Pivot Tables\"  class=\"aligncenter size-full wp-image-11548\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-08.jpg\" alt=\"Data Model and Relationships In Microsoft Excel Pivot Tables\" width=\"1030\" height=\"590\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-08.jpg 1030w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-08-300x172.jpg 300w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-08-1024x587.jpg 1024w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-08-768x440.jpg 768w\" sizes=\"(max-width: 1030px) 100vw, 1030px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #ff0000;\"><strong>STEP 6:<\/strong><\/span> In the\u00a0<strong>ROWS<\/strong>\u00a0section put in the <em><strong>Students(FirstName)\u00a0<\/strong><\/em>field.\u00a0\u00a0In the\u00a0<strong>VALUES<\/strong>\u00a0section put in the <em><strong>Classes (ClassName)\u00a0<\/strong><\/em>field.<\/p>\n<p>With just that, you can see that Excel was able to show the results in a <strong>merged fashion!<\/strong>\u00a0You can see<strong> Daisy has 2 classes enrolled<\/strong>. And from the individual tables, you would not have that information readily available!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Data Model and Relationships In Microsoft Excel Pivot Tables\"  class=\"aligncenter size-full wp-image-11549\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-09.jpg\" alt=\"Data Model and Relationships In Microsoft Excel Pivot Tables\" width=\"983\" height=\"991\" srcset=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-09.jpg 983w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-09-298x300.jpg 298w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-09-150x150.jpg 150w, https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2019\/04\/Data-Model-09-768x774.jpg 768w\" sizes=\"(max-width: 983px) 100vw, 983px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><strong>Further Learning:<\/strong><\/span><\/p>\n<ul>\n<li><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/clean-data-set\/\" target=\"_blank\" rel=\"noopener\">Clean Data Set for Pivot Table<\/a><\/li>\n<li><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/prepare-data-for-pivot-tables\/\" target=\"_blank\" rel=\"noopener\">Prepare Data for Excel Pivot Tables<\/a><\/li>\n<li><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/blog\/move-and-remove-fields-and-items\/\" target=\"_blank\" rel=\"noopener\">Move and Remove Fields and Items in Excel Pivot Tables<\/a><\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline; color: #0000ff;\"><strong>Helpful Resource:<\/strong><\/span><\/p>\n<p><a href=\"https:\/\/www.myexcelonline.com\/meo-staging\/100-5.html\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.myexcelonline.com\/meo-staging\/wp-content\/uploads\/2017\/04\/530x300-Pivot.jpg?x85520\" alt=\"Data Model and Relationships\" width=\"530\" height=\"300\" title=\"\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":17405,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"cos_headline_score":0,"cos_seo_score":0,"cos_headline_text":"","cos_headline_has_been_analyzed":false,"cos_last_analyzed_headline":[],"om_disable_all_campaigns":false},"categories":[4,42],"tags":[590,139,591],"acf":[],"_links":{"self":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts\/11537"}],"collection":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/comments?post=11537"}],"version-history":[{"count":0,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/posts\/11537\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/media\/17405"}],"wp:attachment":[{"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/media?parent=11537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/categories?post=11537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myexcelonline.com\/meo-staging\/wp-json\/wp\/v2\/tags?post=11537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}