How to Visualize Age/Sex Patterns with Population Pyramids: The Tableau Edition

Nov 27th, 2018 / Data Visualization / , , ,

Deven Wisner is a frequent Depict Data Studio collaborator, a personal friend, and an all-around awesome data nerd. Check out his additional articles about getting started with Tableau, customizing fonts, and customizing colors.

—–

If you’re like me, you were probably inspired to revise some of your charts after reading Ann’s How to Visualize Age/Sex Patterns with Population Pyramids. Too often when I storyboard demographic information I default to separating out this demographic information (you know, for the sake of keeping things simple). Unfortunately, this is sometimes a missed opportunity to provide a more comprehensive picture. These things combined inspired me to recreate the Pyramid Chart in Tableau — Let’s get started!

 

The Data

The dataset we’ll be using is from the Arizona Office of Economic Opportunity, which you will see consists of age groups, sex (male/female), and population. If you receive disaggregated data, that wouldn’t be a problem — that’s Tableau’s specialty!


 

The Hack

We want to load our data source, review that our variables came in correctly, and add a new sheet. Next, we’ll drag two Population pills to Columns.

Now drag Age Group to Rows. You will want to click the arrow and uncheck Show Header.

To get our Age Groups in the middle, we need to hack Tableau a bit. Start by creating a Middle calculated field — all you’re doing is entering “0” and saving. Next, drag the Middle pill between your Populations. On the Marks Card, add Age Groups as a text item and change the type to text.

Okay, we’re making progress! Realizing our pyramid (or butterfly) is dabbing, we need to reverse the axis of our population on the left.

Note: You might need to sort Age Groups, as I did (see above where Under 5 years is after 85 years and over).

In order to highlight females on one side and males on the other, we need to create a couple calculated fields.

On the Marks Card, add Female as a text item to one population and Male to the other. Now we have the shape of something, but you probably noticed that the comparison is about as helpful as a table.

To change that, we’re going to get crafty with colors and create a calculated field for each. This will allow us to control the colors independent of one another while still maintaining the same x-axis (i.e. Population).

After creating your Female/Male Color calculated fields, you’ll want to drag them to their respective Color Marks Card. Next, edit the colors and be sure the “0” (i.e. the sex you don’t want to call out) is something very light.

Additional color tips: You’re better than basic — use something other than the default blue and orange Tableau gives you. You should also avoid using traditional blue and pink to represent male/female (this is 2018, after all!).

Our final steps will be cleaning up our visual. First, I want to get rid of unnecessary borders and lines across the entire sheet (they’re just a distraction). I would also hide my axes, as I have labels on my bars.

Speaking of the labels, I want to format (SUM)Female/(SUM)Male to be a nice round number and change my units to thousands (K). You should use your discretion when doing this but for the purpose of this chart, I know my readers aren’t actually distinguishing between 200,010 and 200,500.

Last but definitely not least, I want a descriptive title that pulls readers in. You’ll notice that I also leveraged colors in my title to differentiate between each side of the pyramid.

Bonus: You can go the extra mile and include some great information in your tooltips, too. Often, percentage of an entire population is a really important piece of information. The tooltip is a great way to provide that without adding distractions to the visualization.

 

Deven is a Senior Managing Consultant at Empact Solutions. He is trained in applied psychology, with concentrations in evaluation research, and industrial-organizational psychology. Deven dedicates the majority of his time to building the capacity for data-driven decision making within organizations. He also develops the appreciation, understanding, and use of data through compelling data visualizations using variety of tools. Through evaluation, Deven empowers decision makers to understand the inner-workings of their programs or new initiatives – allowing them to make the most informed decisions. His facilitation experience varies from delivering customized workshops to teaching the Psychology of Leadership & Organizational Behavior for the University of Arizona, South.

Related Courses

Data visualization best practices, practical how-tos, tutorials in multiple software platforms, and guest experts. Designed with busy number-crunchers in mind.
$599

Enroll Now

SPONSORED

#f-post-el-35{display:none !important}

#f-post-el-35{display:none !important}
#f-post-el-35{display:none !important}

Enroll Now