Description
Let’s break some complicated charts into multiple charts in the ways that we have been studying. Begin by downloading the Tableau Packaged Workbook file cac115_multiple.twbxLinks to an external site.. This file contains a set of charts and the data upon which the charts are based. Open the workbook in Tableau Public.
In this project you will be making these improvements to three different charts:
Zooming in on an area chart
Filtering the data in a column chart
Replacing a multiple line chart with a small multiple stacked area chart
We suggest you read through the whole project before you begin.
1. Zooming in on an Area Chart
The “Demand 2019” sheet shows the daily electricity demand in the United States throughout 2019. At this scale, it is easy to see that demand is higher in the summer and winter than in the spring and fall. Looking at the 52 bumps along the line, you can even see that demand is higher in the middle of each week and lower on the weekends. What you can’t see is that there is also a daily fluctuation pattern in demand. To show that, we need a second chart that displays hourly (not daily) data; that chart will need to zoom in to focus on a subset of the X axis.
Your task is to create a second area chart in the sheet “Demand May” using the data source “US Electricity May 2019.” The chart should span enough days to show the daily pattern, but you need not use the whole month. If you show at least two weeks, you should be able to see the same weekly demand pattern we saw in the previous chart. Add an “area” annotation to the “Demand 2019” chart to show which part of the year will be highlighted in the new chart. Your new chart should look something like this:
Tips:
When you add the “Date Time” dimension to Columns, Tableau initially applies the YEAR() function to it. You will want to open the pill’s menu and change that to be the HOUR() function, found in the “More” submenu. Note that there are two sections of time-based functions, and both have “More” sub-menus. The first section aggregates over all dates of the given type. If you chose this section’s HOUR() function, your chart would only show 24 hours with each containing an aggregate value over all of the days in the data. Instead, you want the HOUR() function in the second section, which shows all hours independently along the X axis.
You will want to modify the range and display of the X axis so it looks good. Right-click (Windows) on the date axis and select “Edit Axis…” Here you can set the axis range, tick marks, title, and subtitle (commonly used to specify the axis units). Use the settings from the “Demand 2019” chart as a guide for improving this axis. In particular, note how choosing a “Tick origin” and Interval for the Tick Marks can position the gridlines (see D, below) correctly.
To improve the axis label text, right-click the axis and select “Format…” This shows the Format pane on the left, with the Axis tab selected. Expand the Dates dropdown and choose the “Custom” format at the bottom. Experiment with entering various combinations of the letter “d” as the format. A single “d” displays the date number in its minimum size, while “dd” always shows two digits, “ddd” shows an abbreviation for the day name, and “dddd” spells the name out.
In the Format panel’s toolbar, click the “Lines” button and enable the Grid Lines. We usually want to avoid extra grid lines, but for this chart, they will help viewers see where each day begins and ends.
Don’t forget to set an appropriate title and make sure both axes have good labels and units.
2. Filtering the Data in a Column Chart
The sheet “Movies” shows the top-grossing movies from the years 2006 through 2016. The movie “Cars,” on the left side of the chart, was not among the very highest-earning films of this period, but it is much harder to tell from this chart how well “Cars” did in the year of its release, 2006.
Your task is to create a second column chart in the sheet “2006 Movies” to show how the gross for “Cars” ranked among other movies from 2006. This chart will use the “Movie Data” data source. Add an annotation to both sheets to help viewers locate “Cars” in the column charts. Your new chart should look something like this:
Tips:
You can use the “Movies” sheet as a guide to specifying the Columns and Rows for the new chart.
Use filters to select a range for Revenue and to select only the year 2006.
Be sure to maintain consistent coloring between the two charts.
3. Replacing a Multiple Line Chart With a Small Multiple Stacked Area Chart
The Sheet “BMI” represents a first attempt to display “Body Mass Index” (BMI) data for a dozen European countries. The data set contains percentages of the population that fall within each of four BMI categories, and every data point contains values for four additional dimensions: country, age range, sex/gender, and educational level. The hope had been to display data for several of these dimensions at once, but as this chart shows, just displaying how percentages for one BMI category (“obese”) changed over the age ranges and countries quickly became visually overwhelming. Another approach will be needed just to show all of the BMI categories at once.
Your task is to create a second chart in the sheet “Multiple BMI” using the “BMI Edu Age” data source. This will be a “Small Multiples” chart where each smaller chart displays BMI data for one European country. These will be area charts with age ranges along the X axis and stacked areas representing the percentage of the population in each BMI category (Underweight, Normal, Overweight, and Obese). Assign short names to the BMI categories and order themLinks to an external site. so the least overweight is at the bottom and the most overweight is at the top of the area stack.
Each small chart should be labeled with the name of the country and they should all share the same color scheme and axis scaling. Your new chart should look something like this:
Tips:
The Read pages in this module (“Displaying Large Amounts of Data With Small Multiple Charts,” “Creating Small Multiple Charts in Tableau,” and “Multiple Charts for One Data Dimension in Tableau”) will help you create the chart for this activity.
Since we are not using the data dimensions for sex/gender and educational level, we are essentially summing up six different sets’ (two sexes times three educational levels) worth of percentages for each unique value we display (for each country, an age range, and a BMI category). Consequently, we need to scale the percentage values in the data before using them. A Calculated FieldLinks to an external site. called “Scaled Percent” that divides the Percent measure by 6 was created in the “BMI” sheet for this purpose. It is now part of the “BMI Edu Age” data source, and you should use that field in the Rows of your charts, rather than “Percent.”
The text data for the age range categories are awkward and not suitable for display. An “alias” was created in the “BMI” sheet for each age range. Make sure those aliases have carried over to your new chart by clicking the dropdown menu of the “Age Range” dimension and selecting “Aliases…” If they don’t appear there, you can add and edit them there.
Similarly, the BMI category values are not suitable for display and you will need to provide aliases for them in the legend. Since these aliases were not defined in the “BMI” sheet, you will have to create them now as described in the previous tip.
Make sure that your BMI designations are differentiated by color by dragging “BMI” to Color in the Marks panel.
The previous reading material titled “Multiple Charts for One Data Dimension In Tableau” presented steps for adding labels to “Small Multiple” charts. That example used line charts, and the area charts you are using here behave somewhat differently. Here are a few changes you can make to those instructions for better results in this situation:
Because we know that the stacked area charts will all have a maximum value of 100, the calculated field you create can have a value of 100 to simplify the label positioning. Let’s assume that you do so and call the calculated field “OneHundred”. Now you will not need to edit the axis on the right to give it a “Fixed” range.
When you drag the “OneHundred” calculated field to the right end of Rows, the new charts that appear have the same type as the existing charts (Area). You want Line charts, so use the Marks panel’s dropdown to select Line as the chart type for SUM(OneHundred).
Before selecting “Dual Axis” to merge the Area and Line charts into one, you must remove all of the Marks assignments that were automatically copied from the first set of charts into the new ones for “OneHundred”. If you do not, these will be added to the legend and you will not be able to remove them. Simply drag each (probably a color for BMI and a detail for Country) out of the Marks panel.