Tableau Tutorials

# Creating a Pareto Chart and Population Pyramid

A Pareto chart is a chart containing both bars and a line graph, where individual values are represented in the descending order by bars, and the line represents the ascending cumulative total. It is named after Vilfredo Pareto, an Italian engineer, sociologist, economist, political scientist, and philosopher, who formulated what has become known as the Pareto principle.

In Tableau, you can apply the table calculation to sales data for creating a Pareto chart showing the percentage of total sales that is coming from the topmost products and thus identifying the key segments of your customer base, which are important for your business’s success.

The below procedure uses the Sample – Superstore data source.

### How to create a bar chart that shows Sales by Sub-Category in descending order:

1. Connect to the data source Sample – Superstore.
2. Drag Sub-Category from the Data pane to Columns, and then drag Sales to Rows.
3. Click on the Sub-Category on Columns and choose Sort.

In the Sort dialog box, perform the following:

1. Under Sort order, choose the option Descending.
2. Under Sort by, choose the option Field.
3. Leave all the other values unchanged, including Sales as the selected field and Sum as the selected aggregation.
4. Click on OK to exit the Sort dialog box.

Products are now sorted from the highest sales to lowest sales.

## How to add a line chart that shows Sales by Sub-Category:

1. Drag Sales from the Data pane to the far right of the view until a dotted line appears.
1. Drop Sales to create a dual-axis view.
2. Select field SUM(Sales) (2) on the Marks card, and convert the mark type to Line.

Now the view should look like this:

## How to add a table calculation to the line chart for showing sales by Sub-Category as a running total and as a percent of total:

1. Click the second copy of SUM(Sales) present on Rows and choose the option Add Table Calculation.
2. Add a primary table calculation to the SUM(Sales) to present sales as a running total.

Select option Running Total as the Calculation Type.

Do not close the dialog box Table Calculation.

1. Add a secondary table calculation for presenting the data as a percent of the total.

Click on the option Add Secondary Calculation and select Percent of Total as the Secondary Calculation Type.

Now the Table Calculation dialog box should look like this:

1. Click on the X in the upper-right corner of the Table Calculations dialog box to close.
2. Click on Color in the Marks card to change the color of the line.

The result is now a Pareto chart:

## Create a Population Pyramid:

A population pyramid, also known as the age structure diagram, shows the distribution of various age groups in a population.

A common distribution used in this type of visualization data is female and male populations by age. For creating a population pyramid using Tableau, first separate the population (measure) into two groups, females and males, and then create the bins for the age you want to represent in the population pyramid.

For instance, suppose you are working with a table from the United States Census Bureau containing population, gender, and age data.

For creating a bin and dividing a measure into two groups.

1. Download and open the below workbook.
1. Navigate to https://public.tableau.com/workbooks/CreateaPopulationPyramid.twb.
2. Open the downloaded workbook.
1. Select the option Worksheet > Clear > Sheet.
2. Right-click the Age field in the Data pane, and select Create > Bins.
3. In the dialog box Create Bins, enter a bin size based on the age groups you are interested in focusing on, and then click OK.

In this instance, the bin size is 10 which means that the age cohorts are defined by an increment of 10 years.

1. Drag the bin you have just created to the Rows shelf.
1. Select Analysis > Create a Calculated Field, and then perform the following:
• Enter a name for the calculation. For this instance, enter Male Population.
• Enter a formula similar to the following for isolating the male constituent from the population:

IF [Gender] = 1 THEN [ESTBASE2010] END

In the above case, the census data has defined the Gender value for males as “1.” The field “ESTBASE2010” contains estimated population values.

1. Similar to step 5, select Analysis > Create a Calculated Field, and then perform the following:
• Enter a name for the calculation. For this instance, enter Female Population.
• Enter a formula similar to the following for isolating the female constituent from the population:

IF [Gender] = 2 THEN [ESTBASE2010] END

In the above case, the census data has defined the Gender value for females as 2. The field ESTBASE2010 contains the estimated population values.

1. Drag the calculated fields you have created to the Columns shelf and the Gender field to the Color shelf.
2. Right-click on the axis for Male Population, select Edit Axis, select the check box Reversed to reverse the order the values displaying on the axis, and then click on OK.

After you have changed the sort order of the bin, the population pyramid looks like this:

Facebook Comments

This site uses Akismet to reduce spam. Learn how your comment data is processed.