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:
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:
Can you guess what the Female calc looked like? Yep:
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:
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:
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:
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:
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:
With the Tick Marks set as below:
To fix this, I took this approach. First, I told Tableau how to handle negative values:
If I then clicked Custom, I could see this:
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!
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:
- 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
- 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:
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: