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.
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.
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,
You first fetch all the customer and product data and place them in separate ranges.
Then write a vlookup formula to fetch product category, another to fetch customer gender.
Then fill down the formulas for entire list of transactions.
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,
Create relationships between Sales, Products & Customer tables
Create a pivot table
Creating a relationship in Excel – Step by Step tutorial
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. Read introduction to Excel tables to understand more.
Now, go to data ribbon & click on relationships button.
Click New to create a new relationship.
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.
Add more relationships as needed.
Using relationships in Pivot reports & analysis
Select any table and insert a pivot table (Insert > Pivot table, more on Pivot tables).
Make sure you check the “Add this data to data model” check box.
In your pivot table field list, check “ALL” instead of “ACTIVE” to see all table names.
Select fields from various tables to create a combined pivot report or pivot chart
Example: Category & Gender Sales Report
Add category to row labels
Add gender to column labels
Add quantity to values
and your report is ready!
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?
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.
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.
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
Holy information/data overload. There are some great visualizations here, but also that are not so good. This list may have been better in small chunks.
[...] has progressed. With one look you can see on what issues candidates debated most. Also see these 35 different visualizations on 2008 US Elections [via Information [...]
[...] Red vs. Blue - 35 Cool Visualizations on 2008 US Presidential Election Perspctv - another Election Tracking Site. Presidential Watch - what various websites are saying. The Economist’s pole - Economists prefer Obama over McCain. NYTimes - Poll Tracker. Gallup poll tracker… Google Maps Projections Tracker … [...]
First let me say that I love this blog. I have been scouring the Internet and more than likely overlooking the obvious. Can someone lead me to the OFFICIAL source of elections results? I am looking for voter data by county or even town if possible.
The reason I ask is because on Boston.com, they listed the results by town, and have to assume that there is an offical source.
Anyway, any help you can provide will be greatly appreciated!
@Brock: Thank you so much. I guess fec.gov should put up the results as soon as all counties report the results officially. I dont know but I guess it should take a few days before the data is compiled and released to public.
Alternatively did you see what nytimes.com has to offer? They have a county level breakup of results and majority figures in visualization form.
[...] to give a deeper insight into the elections. A top 35 of those visualizations are listed in the Chandoo.org website. B. Shneiderman’s very interesting network analysis of the Senatorial voting patterns is [...]
21 Responses to “Red vs. Blue – 35 Cool Visualizations on 2008 US Presidential Election”
[...] Read the rest of this great post here [...]
[...] post by WP-AutoBlog Import var AdBrite_Title_Color = '0000FF'; var AdBrite_Text_Color = '000000'; var [...]
Impressive list, though a few of these clearly qualify as junk (the second one with the hairy circle segments, for example).
Also, that McCain vs. Obama tax plan comparison is wildly distorted, for a debunking and redesign see here: http://chartjunk.karmanaut.com/taxplans/
Holy information/data overload. There are some great visualizations here, but also that are not so good. This list may have been better in small chunks.
[...] Haired Dilbert has some pretty cool visualizations for the ‘08 Election featured on his blog. I really liked this [...]
Cool list!
I know another widget that might have your interest.
It shows the progression of polls and uses data from electoral-vote.com.
I think you might like it:-)
http://www.youcalc.com/apps/1221747067033
... and its easy to put on your blog and fits in your sidebar!
Make a difference, keep on voting!
@Robert .. Agree, few of the charts are not really great. thanks for link, I have updated the post with the link.
@Tony ... That was the point. I wanted to compile a huge list with all the visualizations worth a look.
@Michael .. Welcome to PHD blog 🙂 thanks for sharing that link.
[...] Check the rest out here. [...]
[...] has progressed. With one look you can see on what issues candidates debated most. Also see these 35 different visualizations on 2008 US Elections [via Information [...]
[...] Red vs. Blue - 35 Cool Visualizations on 2008 US Presidential Election Perspctv - another Election Tracking Site. Presidential Watch - what various websites are saying. The Economist’s pole - Economists prefer Obama over McCain. NYTimes - Poll Tracker. Gallup poll tracker… Google Maps Projections Tracker … [...]
[...] Aqui pode igualmente encontrar uma compilação de 35 [...]
[...] 35 Cool Visualizations on 2008 US Presidential Election - Obama vs. McCain [...]
[...] Also see these 35 visualizations from on Obama vs. McCain in US Polls. [...]
First let me say that I love this blog. I have been scouring the Internet and more than likely overlooking the obvious. Can someone lead me to the OFFICIAL source of elections results? I am looking for voter data by county or even town if possible.
The reason I ask is because on Boston.com, they listed the results by town, and have to assume that there is an offical source.
Anyway, any help you can provide will be greatly appreciated!
@Brock: Thank you so much. I guess fec.gov should put up the results as soon as all counties report the results officially. I dont know but I guess it should take a few days before the data is compiled and released to public.
Alternatively did you see what nytimes.com has to offer? They have a county level breakup of results and majority figures in visualization form.
Thanks for your help!
[...] 35 Cool Visualizations on 2008 US Presidential Election - Obama vs…. [...]
@Brock: You can get the data from USAToday site : http://www.usatoday.com/news/politics/election2008/president.htm
just scroll down and select the state name to see its county results in tabular form.
Thanks again. I also stumbled upon this. http://general-election-2008-data.googlecode.com/svn/trunk/json/votes/2008/. It appears as if there was a Google project with the data. I do not know a web programming language, but I am sure there is an easy way to catch the data and put it into a database.
[...] to give a deeper insight into the elections. A top 35 of those visualizations are listed in the Chandoo.org website. B. Shneiderman’s very interesting network analysis of the Senatorial voting patterns is [...]
ts not cool or notx