“How Trump happened” in Excel [visualizations]

Share

Facebook
Twitter
LinkedIn

During last week, an alert reader of our blog, Jørgen emailed me a link to “How Trump happened“.  It is an interactive visualization by Wall Street Journal. Jørgen asked me if we could replicate the visualization in Excel. My response: “Making a new chart in Excel? Hell yeah!”

First let’s take a look at the WSJ visualization:

You may go to WSJ’s How Trump happened page or see a quick video below. Make sure you are seeing the WSJ link on a computer or tablet. On mobiles it changes to a bar chart.

If you have trouble watching the video, click here.

As you can see, the visualization starts with one hundred voters in each group and shows how they are divided by various issues. It is a very interesting piece of story telling. That said, I am not a fan of it for below reasons:

  • Misleading: The visualization suggests that some of the voters who said “YES” for one issue are saying “NO” to another. For example, 40% Trump voters have >$75,000 income. But when you go next issue (Do you have college degree?), you see 2 % voters moving to NO group. This suggests that out of 40% who have >$75k income, only 2% do not have college degree. But this is not true. The groups having $75k income and college degree may be completely different (or 100% overlapped).
  • Time consuming: We need too much time to digest 10 issues at hand. What more, We are unable to compare issues vs. candidates because of we can’t see everything in one go.
  • Poorly named: Last but not least, the visualization is wrongly titled. It doesn’t really explain how Trump happened? It never mentions what motivated the voters to side with Trump, whether Trump’s own campaign promises / manifesto align with the issues these voters worry about. For most of the issues, there are no significant differences between 3 groups of candidates. So how a voter decided to go with Trump is never explained.

Okay, so how do we create this in Excel?

We can’t. At least, I can’t make a 100% replica of the WSJ chart in Excel. So I went with next closest approximation. Here is the basic approach:

  • We create a bubble chart with 3 bubbles – top, bottom and move.
    • Top bubble shows how many people answered YES for a particular issue
    • Bottom bubble shows how many answered NO
    • Move bubble shows people moving from one group to another as we switch between issues.
  • We fill the bubbles with people shapes and tile them.
  • Whenever we switch to a new issue,
    • We calculate the new top & bottom bubble sizes
    • We figure out the move bubble size and movement direction (ie top to bottom or bottom to top?)
    • In case of top to bottom movement,
      • Use VBA to gradually reduce the top bubble while increasing the move bubble
      • Change the move bubble’s y value from top to bottom
      • Increase the bottom bubble size while reducing the move bubble size gradually
    • Do the opposite in case of bottom to top movement.
  • Use a slicer to capture issue selection and trigger animation VBA.

Here is a quick demo of this approach:

Watch this quick video. Click here if you can’t see it.

An alternative visualization – Trump Tower chart

Let me confess a thing. I don’t like the bubble chart approach. It feels clumsy and complex. So I wanted to try something different. How about using two ranges of cells and simply filling them up based on how many people said YES and NO. When we switch to a different issue, we simply move the filled cells from one range to another.

I call this approach, the trump tower chart. 

First, take a look at it:

how-trump-happened-xl-v2

How is the Trump Tower constructed?

Oh, simple. We just go to the bank, take a $ 100 mn loan, go to city council and convince them to allocate acres of land, construct a big, luxurious building, sell the condos for insane prices and bag the profit.

I am kidding. Don’t rush to the bank. We can use Excel to make the chart. Here is the approach in a nut shell.

  • Create two ranges of cells: top & bottom each with 100 cells
  • Using conditional formatting, fill up the top range with number of people saying YES and bottom range with number of people saying NO.
  • When user switches to a new issue, using VBA:
    • Calculate the new Top & Bottom sizes
    • Calculate the direction of movement
    • If voters are going from top to bottom, for each voter moving:
      • Reduce the top range size by 1
      • Create moving illusion by filling up blank space between ranges
      • Increase bottom range size by 1
    • Do the opposite if we are going from bottom to top
  • Set up a scroll bar to enable issue selection. Link the scrollbar to Animate VBA macro

Isn’t there a better way to visualize this data?

Let’s be honest. The original WSJ chart and both our interactive + animated replicas are not the ideal way to understand this data. These are complex – both to create and read. As we always say, simplicity trumps. Or as Trump says, “Let’s make charting great again”. So let me present a chart that is amazingly clear and very easy to make.

A bar chart will do:

As you can guess, a simple bar chart is enough to understand this data. Should you wish to highlight polarizing issues, you can use conditional formatting to highlight them. See below image:

how-trump-happened-bar-chart

Download “How Trump happened” Excel workbook:

Click here to download the how trump happened workbook. It contains all three visualizations. Please enable macros to enjoy them. Examine the code.

So which one is your favorite?

While I had a lot of fun building the bubble chart & Trump tower versions, I think the bar chart is most useful version.

What about you? Which chart do you like most? How would you visualize this data? Please share your thoughts and suggestions in the comments area.

Build your charting muscle…

Visual story telling is a very compelling medium. Learn how to build awesome charts using Excel. Check out below tutorials and examples:

Facebook
Twitter
LinkedIn

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.

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 storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
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.

13 Responses to “Using pivot tables to find out non performing customers”

  1. David Onder says:

    To avoid the helper column and the macro, I would transpose the data into the format shown above (Name, Year, Sales).  Now I can show more than one year, I can summarize - I can do many more things with it.  ASAP Utilities (http://www.asap-utilities.com) has a new experimental feature that can easily transpose the table into the correct format.  Much easier in my opinion.

    David 

    • Chandoo says:

      Of course with alternative data structure, we can easily setup a slicer based solution so that everything works like clockwork with even less work.

  2. Martin says:

    David, I was just about to post the same!
    In Contextures site, I remember there's a post on how to do that. Clearly, the way data is layed out on the very beginning is critical to get the best results, and even you may thinkg the original layout is the best way, it is clearly not. And that kind of mistakes are the ones I love ! because it teaches and trains you to avoid them, and how to think on the data structure the next time.
     
    Eventually, you get to that place when you "see" the structure on the moment the client tells you the request, and then, you realized you had an ephiphany, that glorious moment when data is no longer a mistery to you!!!
     
    Rgds,

  3. JMarc says:

    Chandoo,
    If the goal is to see the list of customers who have not business from yearX, I would change the helper column formula to :  =IF(selYear="all",sum(C4:M4),sum(offset(C4:M4,,selyear-2002,1,columns(C4:M4)-selyear+2002)))
     This formula will sum the sales from Selected Year to 2012.

    JMarc

  4. Elias says:

    If you are already using a helper column and the combox box runs a macro after it changes, why not just adjust the macro and filter the source data?
     
    Regards

  5. RichW says:

    I gotta say, it seems like you are giving 10 answers to 10 questions when your client REALLY wants to know is: "What is the last year "this" customer row had a non-zero Sales QTY?... You're missing the forest for the trees...
    Change the helper column to:
    =IFERROR(INDEX(tblSales[[#Headers],[Customer name]:[Sales 2012]],0,MATCH(9.99999999999999E+307,tblSales[[#This Row],[Customer name]:[Sales 2012]],1)),"NO SALES")
    And yes, since I'm matching off of them for value, I would change the headers to straight "2002" instead of "Sales 2002" but you sort the table on the helper column and then and there you can answer all of your questions.

  6. Kevin says:

    Hi thanks for this. Just can't figure out how you get the combo box to control the pivot table. Can you please advise?
     
    Cheers

  7. Kevin says:

    Thanks Chandoo. But I know how to insert a combobox, I was more referring to how does in control the year in the pivot table? Or is this obvious?  I note that if I select the Selected Year from the PivotTable Field List it says "the field has no itens" whereas this would normally allow you to change the year??
     
    Thanks again

  8. Kevin says:

     
    worked it out thanks...
    when =data!Q2 changes it changes the value in column N:N and then when you do a refreshall the pivottable vlaues get updated 
     
    Still not sure why PivotTable Field List says “the field has no itens"?? I created my own pivot table and could not repeat that.

  9. Bermir says:

    Hi, I put the sales data in range(F5:P19) and added a column D with the title 'Last sales in year'. After that, in column D for each customer, the simple formula

    =2000+MATCH(1000000,E5:P5)

    will provide the last year in which that particular customer had any sales, which can than easily be managed by autofilter.

    • Bermir says:

      Somewhat longer but perhaps a bit more solid (with the column titles in row 4):

      =RIGHT(INDEX($F$4:$P$19,1,MATCH(1000000,F5:P5)),4)

Leave a Reply