In this chapter, you'll create pivot charts using the food sales data you worked with in Chapters 8 and 9. A pivot chart paints a picture of the data in a pivot table and can make the data easier to understand. Instead of a table full of numbers, a pivot chart can use columns, bars, or pie slices to illustrate the numbers, and a pivot chart lets you easily compare results between years, regions, or products. Or, a pivot chart can use lines to show how results change over time (see Figure 11-1).
Figure 11-1. Pivot chart comparing 2006 vs. 2007 sales
To start, you'll create a simple column chart with the default chart settings. You'll modify that chart's layout, change its appearance, and move the pivot fields to produce a custom-tailored chart that presents your data effectively. Then, you'll create a line chart from the pivot table data to compare sales over two years. You'll add labels, titles, and trend lines to the chart to ensure that your chart is easy to understand.
Finally, you'll see how easy it is to use the pivot chart filters to instantly create a chart that shows results for a different product or region. With one click of the mouse, your chart can focus on cookie sales instead of snacks or on the east instead of the north. What might take hours to achieve with regular charts will take seconds to create with a pivot chart.
The sales manager at your food sales company is preparing for a regional sales meeting and wants a chart that compares each region's sales for each product type. You'll create a pivot chart with the default settings, and then you'll modify the chart to improve its appearance.
To start, you'll open the sample food sales workbook and prepare the pivot table:
RegionSales_03.xlsx
, available from the Apress web site.The pivot table is based on sales data for the East and North regions for 2006 and 2007. The chart should compare sales in the two regions for all the product types, so you'll add the Region, ProdType, and TotalPrice fields to the pivot table layout and then create a pivot chart from the pivot table.
At this point, you aren't sure how the fields should be arranged for the pivot chart, so you'll add the fields where they'd make sense in a pivot table report. After you create the pivot chart, you can change the layout, if required.
This creates a concise summary of the data, and you can compare the sales between regions for each product type.
Figure 11-2. A default pivot chart
The chart that was created is the default chart type, a clustered column chart. In the PivotTable Field List pane, the Row Labels area has changed to the Axis Fields (Categories) area, and the Column Labels area is now called the Legend Fields (Series) area (see Figure 11-3).
Figure 11-3. The area names have changed in the PivotTable Field List pane.
The region names are shown on the category axis, which is the horizontal axis across the bottom of the chart. Above each region name on the axis is a cluster of colored columns.
The product types from the ProdType field are shown in the legend at the right of the chart. The ProdType items are series in the chart, and there is a column that represents the total sales for each product type in each region. The colored square beside the ProdType name in the legend indicates which color its columns are. For example, the two blue columns represent the bar sales, one for the East region and one for the North region.
Figure 11-4. A tool tip shows information about the column.
Tip You can point to any element in the active chart and see its name in a tool tip, if tool tips are enabled.
The red column in the East region is the tallest column in the chart. The legend shows that red columns represent sales of cookies, so cookies in the East region are the best-selling product type per region. Snacks in the East and North regions have the smallest columns, indicating that sales of snacks are the lowest, and they look very close in sales for the two regions.
In addition to the PivotTable Field List pane, when the pivot chart is active, a PivotChart Filter Pane becomes available (see Figure 11-5). This lets you sort and filter the fields, just as you can in a pivot table, and you can use the row labels, column labels, and report filters.
Figure 11-5. The PivotChart Filter Pane
You'll use the PivotChart Filter Pane to temporarily filter the product types to show only the snacks. This will remove the product types with more sales and will let you focus on snacks and see the small difference between the values those columns represent.
The color for the Snacks column changes to blue, because that is the color used for the first column in the chart. The scale in the vertical axis at the left changes and shows a much smaller range of numbers. Previously, it went from 0 to 180000, and it now goes from 21500 to 21720. This magnifies the difference between the two columns, and you can clearly see that the North region had more sales (see Figure 11-6).
Figure 11-6. Pivot chart filtered to show only snacks
Now that you've focused on the snacks sales, you'll remove the filter from the pivot chart so it shows all the product types:
All the product types are visible again, and the vertical axis scale starts at zero and goes to 180000.
On the PivotChart Filter Pane is a Field List button that lets you show or hide the PivotTable Field List pane. You'll hide the PivotTable Field List pane temporarily to see how the pivot chart looks when it's hidden:
Figure 11-7. Field List button on the PivotChart Filter Pane
This creates more room on the screen for the pivot chart, so you may want to hide the PivotTable Field List pane after you have finished the pivot chart layout and are formatting the pivot chart. For now, you'll turn the PivotTable Field List pane back on.
Currently, the chart shows all the product types for the East region in one column cluster at the left of the chart. At the right of the chart is another column cluster that shows all the product types for the North region. This is an ideal arrangement for comparing the product type sales within each region.
To make it easier for the sales manager to compare the results for each product type between regions, you want the related product type columns displayed side by side. Instead of a cluster for each region, you want a cluster for each product type (see Figure 11-8).
Figure 11-8. Cluster columns by region or by product type
Just as you can move fields in a pivot table, you can also move fields in a pivot chart. You'll change the position of the ProdType and Regions fields to create the layout you want for the chart:
Note If the PivotTable Field List pane is not visible, you may have clicked outside the pivot chart. Click in the pivot chart to activate it, and the PivotTable Field List pane should become visible. If it is still not visible, click the Field List button at the top right of the PivotChart Filter Pane.
The pivot chart now shows the product type names along the category axis and the region names in the legend. The East region's sales are represented by blue columns, and the North region's sales are represented by red columns. It's easier to compare the product type sales between regions when the columns are side by side (see Figure 11-9).
Figure 11-9. The product type names on the category axis
With the columns clustered by product type, it's easy to see that sales of bars and cookies are greater in the East, cracker sales are higher in the North, and snack sales are almost equal in the two regions.
Before you send the pivot chart to the sales manager, you want to make it a bit more visually appealing. A title could explain the chart contents, and the legend might be easier to read in a different position in the chart.
When you create a pivot chart, a chart layout is automatically applied. The current layout has the legend at the right, grid lines running horizontally across the chart, and no chart title. You'll select a different layout to quickly give the chart a different appearance.
On the Ribbon, under PivotChart Tools, there are four tabs—Design, Layout, Format, and Analyze—that contain commands you can use when working with a pivot chart. You'll use these commands as you work with the pivot charts in this chapter.
The Chart Layouts gallery shows miniature representations of the layouts that are available. For example, Layout 1 looks similar to the current layout, with grid lines and a legend at the right, but it includes a chart title. Layout 4 has the legend at the bottom, no grid lines, and numbers at the top of each column. You'll choose Layout 2, which has a chart title and legend at the top, no grid lines, and numbers at the top of each column. It also shows that the columns will be slightly separated.
Figure 11-10. The Chart Layouts gallery
The chart layout you clicked is applied to the pivot chart. This layout has a chart title, and the legend is displayed at the top of the chart, where it's easier to see. The grid lines have been removed from the chart, as has the value axis that was at the left side of the chart. Instead, the values are displayed at the top of each column, and the columns are slightly separated in each cluster.
Next, you'll change the chart title so it shows information about the food sales instead of the generic text.
Figure 11-11. The chart title is selected.
Now that the chart layout is the way you want it, you'll change the chart style, which controls the colors and effects that are used in the chart. When you create a pivot chart, a default chart style is automatically applied. You'll select a different chart style to quickly give the chart a more dramatic appearance.
In the Chart Styles gallery, Style 2 is selected, because that is the style currently applied to the pivot chart. The sales manager has asked for blue coloring in the pivot chart, so you'll select one of the options in the third column of styles.
Figure 11-12. Select a chart style.
The chart style you clicked is applied to the pivot chart. This style uses light and dark blue tones to color the columns, and the columns have a beveled appearance. There is good contrast between the column colors for the two regions, and the chart is clean and easy to read (see Figure 11-13).
Figure 11-13. The completed pivot chart
Now that it's ready, you can send the pivot chart to the sales manager.
The sales manager thinks the pivot chart will be a helpful tool for the sales meeting and asks whether you can create another chart showing the same information but with the region totals broken down by city. For example, in the column that shows sales of cookies in the East, how much was sold in Boston and how much was sold in New York?
You'll add the City field to the pivot chart layout so the chart will show the amount per city for each product type. You'll also change the chart type so the cities for each region will be displayed in a single column in the chart.
The City field is added to the Axis Fields (Category) area, and the cities are displayed along the category axis in the pivot chart, within each product type. The columns for the cities are colored according to region, but the chart is crowded and difficult to read. The city totals for each product type are displayed, but the chart no longer shows a direct comparison of the totals per region for each product type.
On the category axis, you want the product type to remain where it is, and above that, you want the region names as they were before. The legend should show the city names so you can identify the cities in the chart's data. To create this layout, you'll change the position of the Region and City fields in the chart layout.
The chart layout is now close to what you need, but instead of a cluster of cities for each region, you want a single column for each region. In the next step you'll change the chart type, and this will achieve the layout you need.
When you create a pivot chart by pressing the F11 key, the default chart style is used. Unless you have changed the settings, the default chart style is a clustered column chart. In this chart, you want the cities for each region stacked in a single column for each product type. You'll change the chart type so the columns are stacked instead of clustered.
Figure 11-14. Change Chart Type command on the Ribbon
The Change Chart Type dialog box opens and shows a list of chart types at the left. At the right are the subtypes available for each chart type. You can point to a subtype and see its name in a tool tip.
You'll continue to use the Column chart type for this chart, but you can see the other chart types that are available in Excel:
Note Although they are available in the list of chart types, you cannot use the XY (Scatter), Bubble, or Stock chart types when creating a pivot chart.
In the Change Chart Type dialog box, the current chart type, Column, is selected, and in the Column section at the right, the current chart subtype, Clustered Column, is selected. You'll select Stacked Column instead so the city data is stacked in a single column instead of being displayed in multiple columns.
Tip Avoid using the three-dimensional chart subtypes, because they will distort the representation of the data in your charts.
Figure 11-15. Select the Stacked Column chart type.
With stacked columns, the chart is now easier to read, but it's difficult to distinguish the cities, since the legend colors are so similar. You'll change the chart layout and style to make it easier to identify the cities.
Note If you select a layout that includes a chart title, the existing title will be retained.
Figure 11-6. Select Style 10 in the Chart Styles gallery.
With the different colors in the chart, it's easier to identify each city's sales in the stacked columns (see Figure 11-17). You can send the revised chart to the sales manager.
Figure 11-17. The completed stacked column chart
Now that you've finished working on the pivot chart, you'll return to the pivot table on which the pivot chart is based to see the effect that these changes to the pivot chart have had:
The pivot table and pivot chart are connected, and the changes you make to one will affect the other. In some cases, this won't be a problem, and you can lay out the pivot table and pivot chart as you require. However, sometimes you've spent a considerable amount of time setting up a pivot table or pivot chart and want it to stay in that layout for your weekly or monthly reports.
In these situations, you can create a second pivot table from the source data and create a pivot chart from that pivot table. Use the first pivot table for your printed reports, and when you make changes to the pivot chart, it will affect the second pivot table, which isn't used for your printed reports.
The sales manager has asked you to create another report for the sales meetings. In this chart, you should show the monthly quantities of bars sold in 2006 and 2007. At the meeting, this chart can show whether bar sales are going up or down and will show the strong and weak sales months for each year.
When you created the first chart, you used the F11 key to create a default chart. This time, you'll use a Ribbon command to create the chart so you'll have more control over the chart setup.
You don't want to affect the existing pivot chart, so you'll create a copy of the pivot table and base the new chart on the pivot table copy. First you'll copy the pivot table, and then you'll change its layout to include the fields you'll need in the new pivot chart:
Now that the pivot table layout includes the fields you need, you can create the pivot chart.
Figure 11-18. PivotChart command on the Ribbon
In the Insert Chart dialog box, the default chart type is selected. Unless you have changed the setting, this is the Clustered Column chart type. A column or bar chart works well when comparing specific values, as you did in the previous chart. Because the new chart will show changes over time, a line chart will be best, so you'll select that chart type for your new pivot chart.
In the chart subtypes at the right, the default line type, Line with Markers, is selected. For this chart, you prefer a line without markers, so you'll select a different line chart subtype.
A line chart appears on the Pivot_Years worksheet, showing the bar sales for 2006 and 2007 (see Figure 11-19).
Figure 11-19. Pivot chart with Line chart type
The pivot chart contains the data you need for the sales manager, but it needs a few improvements before it's ready to send.
In the pivot chart, the two years are shown in a single line, with the dates stretching across the axis at the bottom. The legend shows a line for this series, with its name of Total. Instead of this layout, with a single series, you want each year shown as a separate line, and the legend should show an entry for each year. The Category Axis should show the months but not separated into years.
To create a series for each year, instead of a single series, you'll change the field layout in the PivotTable Field List pane. You want the years in the legend, so you'll move the Years field there.
This layout change creates two series, one for each year, and both show up in the legend. The category axis shows the 12 months, and the lines show the quantity of bars sold each month. However, when the 2006 series was created, it received the default formatting of a line with markers, so you'll change its formatting.
In the pivot chart, the 2006 series is formatted as a line with markers. You'll change it so its formatting is the same as the 2007 series. To format any element in the chart, you can select the element and then apply the formatting.
Figure 11-20. Chart Elements list on the Ribbon
Tip The Chart Elements list is also available on the Format tab of the Ribbon.
The Chart Elements list shows all the elements in the active chart, and you can click any element's name to select that element in the chart. Using this list is an easy way to select the elements and to ensure you're selecting the element you intended to select.
Tip In the pivot chart, click an element, such as a line, or the legend to select it.
In the pivot chart, the line for the 2006 series is selected, and now you can format it.
The Format Data Series dialog box opens, with a list of formatting options for the selected data series. When you click an option in the list, the formatting options appear at the right. For example, you could click Line Style and change the line width and dash type. You want to remove the markers from the selected series, so you'll change the marker options.
Figure 11-21. Marker Options command
In the pivot chart, the markers in the line for the 2006 series have been removed.
Currently, the pivot chart does not have a title, so you'll add one to explain the contents of the chart. In the previous chart, you applied a chart layout that included a chart title, but in this chart you don't want a package of chart formatting. You want to keep the formatting that already is applied and just add a chart title at the top of the chart.
Instead of using a chart layout, you'll use a different command from the Ribbon:
Figure 11-22. Chart Title options
If the chart had a title you wanted to remove, you could use the first option, None. Since you want to add a title, you'll use one of the other two options. The second option, Centered Overlay Title, adds a title at the top of the chart on top of whatever elements are already there. This option is ideal if there is plenty of blank space at the top of the chart and you can display the title there without blocking the other elements.
The third option, Above Chart, will make the chart area smaller and add the chart title in the newly created blank space above the chart area. This option is best if there are other elements at the top of the chart and you don't want to cover them. For your chart, this will be the best option, since the lines are near the top of the chart.
You can also use the Ribbon commands to change the legend position. Currently the legend is at the right of the chart. If you move it to the top, there will be more space for the 12 months that are displayed on the category axis at the bottom of the chart.
Tip You can click the legend to select it, point to the legend's border, and drag it to any position in the chart area.
When you create a pivot chart, it is automatically sized. You can change the chart size by manually adjusting it or by setting an exact width and height. You'll make the pivot chart a bit smaller so it doesn't overlap the pivot table:
Figure 11-23. Manually resizing the pivot chart
Tip To make the pivot chart a specific height or width, enter a value in the Shape Height or Shape Width box in the Size group on the Ribbon's Format tab.
When you use the Ribbon command to insert a pivot chart, it is inserted in the center of the worksheet window. You can drag the pivot chart to a new location on a worksheet or cut it and paste it onto a different worksheet.
You can also use a command to move the chart to a different location. You'll use a command to move the pivot chart to its own chart sheet. This will make the chart larger, and it will be easier for the sales manager to see the details in the chart.
Tip You can right-click the chart area of a pivot chart and choose Move Chart.
The pivot chart is moved to a new sheet, where there is more room to display all the elements without crowding.
When you create a pivot chart, there are no labels on the data to show the values that the lines or bars represent. In some charts, you may want to add labels to some or all of the points on the line or to the columns or bars in the chart.
Before you send this chart to the sales manager, you'll add data labels to the lines. First you'll add data labels to all the points in both lines to see how that looks:
Adding the data labels has cluttered the pivot chart, and where the lines overlap, it's hard to read the numbers and to tell which number belongs to which line (see Figure 11-24).
Figure 11-24. Overlapping data labels
Instead of having each point labeled, you want to label just the last point on each line. You'll remove the data labels and then label just the last points to show the final value for each year.
Tip To quickly add a label with the series name and value to the last point of each line, click the Design tab on the Ribbon, and in the Chart Layouts, click Layout 6. However, this layout will apply other formatting options in addition to the last point label. You could apply the layout first and then finish formatting the chart.
Figure 11-25. The last point on the line is selected.
Tip You can select each data label and format it with a font color that matches the data series line.
Next, you'll add a trend line to each year's line to see whether sales are going up or down over the year:
The trend line for 2006 rises slightly over the year, and the 2007 trend line is downward. The trend lines have also been added to the legend as Linear (2006) and Linear (2007). To make the trend lines stand out a bit more in the chart, you can make the lines thicker and format each with a different color:
Figure 11-26. Trend lines added to the pivot chart
You send the updated chart to the sales manager for discussion at the sales meeting. Perhaps a plan can be devised to increase the bar sales in 2008.
Soon after you send the chart, the sales manager calls to ask whether you can create a similar chart for each of the product types. Perhaps the other product types also have declining sales and should be discussed at the sales meeting.
Instead of creating separate charts, you'll show the sales manager how to select a different product type during the meeting. You'll change the chart title so it will show the name of the selected product type. To make the chart title variable, you'll create a formula on the pivot table worksheet, and then you'll link the chart title to that cell.
Figure 11-27. Formula for variable chart title
The chart title will remain the same, because Bars is still selected as the product type. The title will change when a different product type is selected.
The chart title changes to show that Cookies is the selected product type, and the lines show the monthly quantities of cookies sold. During the meeting the sales manager will be able to select any product type from the PivotChart Filter Pane and lead a discussion on that product type's sales results.
Instead of creating four separate charts, one for each product type, you were able to create a dynamic chart that can be changed with the click of the mouse during the meeting. It will be easier for the sales manager to work with one chart, instead of several, and you saved considerable time in preparation.
When you select a pivot chart, four tabs with pivot chart commands are available on the Ribbon on the PivotChart Tools tab. In the examples in this chapter you used some of these commands to format and design the pivot charts, and many others are left for you to explore on your own.
When you create a pivot table, experiment with the options and features that are available, and see what works best to enhance your pivot charts. For example:
Try to keep the chart's message clear, though, and not buried under a load of unnecessary formatting and frills.
In this chapter, you created pivot charts to illustrate the data in a pivot table. This can make the data easier to understand and provides a visual comparison of the data.
First, you created a default pivot chart by pressing the F11 key. Then, you used the Chart Styles gallery and the Chart Layout gallery options to change the appearance of the pivot chart. You changed the chart type to show related items in a single column, instead of multiple columns. After making the changes, you viewed the pivot table to see that the pivot chart changes had also affected the pivot table on which it was based.
You also created a pivot chart by using the Ribbon commands and modified it to show multiple series, instead of a single series. You formatted the series to remove the markers and added a chart title. You moved the chart legend and then resized and moved the pivot chart. You added data labels to show the numeric value of the last points in each of the series lines and added trend lines to show whether sales were increasing or decreasing over each year.
Finally, you entered a formula on the worksheet and linked the chart title to that cell. This created a dynamic chart title, which will change when the chart filter is changed. With these tools, you have a powerful tool for data analysis that can be changed with one click of the mouse.
13.59.36.133