Today, Andy Kriebel posted a Data School Gym challenge wherein you needed to create a population pyramid. The challenge is here:

And the dashboard looks like this:

Screen Shot 2016-08-12 at 21.05.35

My interpretation

Before starting, my immediate instinct was that the main area chart element of the dashboard was perhaps two separate area charts (one for Males, one for Females) back to back, with one on a reversed axis to retain the positive values on the x-axis. So I attempted to recreate the viz based on an earlier challenge. It didn’t work, because when I looked at Andy’s viz again, it was clear that we were dealing with a single axis chart. Back to the drawing board.

When I finally sussed it out, and it took a couple of hours, the realisation dawned yet again that it just took a couple of simple tricks to create that main area chart. First up: a trio of calculated fields. It’s clear that to have Male and Female populations on the same axis, back to back, that you have to invert one measure. So, the Male population was identified and calculated like this:

Screen Shot 2016-08-12 at 21.12.55

Can you guess what the Female calc looked like? Yep:

Screen Shot 2016-08-12 at 21.14.53

The problem here is that I still have positive values for both Genders, so if I plot them on an area chart, I’ll get this:

Screen Shot 2016-08-12 at 21.16.27

I’ll leave it to your imaginations to decide what the Albanian population in this view could be regarded as looking like. No, what I needed to do was flip the values on one of the Genders, and I simply did this for the Female population:

Screen Shot 2016-08-12 at 21.15.02

So, what’s next? Well, I always get a bit confused when dragging multiple Measures onto a shelf, so I just whack Measure Values on the Column shelf, which reveals this:

Screen Shot 2016-08-12 at 21.27.12

To refine the view at this point, I just whip out the green pills on the Measure Values card in the bottom left. I know I want to retain the ‘Female -‘ and ‘Male’ pills, so I just drag the other three out of the card:

Screen Shot 2016-08-12 at 21.33.05

Perfect! Ah – what about that axis? The Female values are negative! How to address this? Formatting. I thought I was being clever initially, by setting some custom formatting on Population like this:

Screen Shot 2016-08-12 at 21.34.18

With the Tick Marks set as below:

Screen Shot 2016-08-12 at 21.34.58

To fix this, I took this approach. First, I told Tableau how to handle negative values:

Screen Shot 2016-08-12 at 21.43.58

If I then clicked Custom, I could see this:

Screen Shot 2016-08-12 at 21.44.49

It’s such a simple fix when I look back! Just edit that custom format to remove the ‘-‘ value, and the axis will format numbers in the same way, whether positive or negative!

Screen Shot 2016-08-12 at 21.46.10

One final thing of note on this chart is the vertical axis. Eagle-eyed readers will have noted that it jumps from 1950 to 2015 with no intermediate years listed. This is achieved via a combination of two things:

  1. You need a Continuous axis if you want to be able to edit that axis. The Green Continuous pill is visible in many of the images above
  2. Once that is enabled, you can just edit the axis, select the Tick Marks tab, and control the start point of the axis, and the gap between the marks:

Screen Shot 2016-08-12 at 21.48.46

As with every post of mine, these are probably regarded as incredibly basic “tricks” by more experienced Tableau users, but the sheer volume of these little tricks can be hard to take on board, so I’ve documented them accordingly. Hope it helps a fellow Tableau noob.

My final dashboard wasn’t perfect, but it was a decent effort:!/vizhome/DataSchoolPopulation/Dashboard1