# Create and use a stacked bar chart

Stacked bar charts display the relative size—either as a count, percentage, or other numeric variable—of a categorical variable, subdivided by color based on a subgroup.

Stacked bar charts can answer questions about your data, such as How are numeric values distributed or summarized by category and subcategory? How is your data ranked?

## Example

An insurance company is reviewing the types of policies it offers to compare its current offerings to the findings from a recently completed market research project. The insurance company is especially interested in expanding its business in five cities of interest. A stacked bar chart can be used to visualize the sum of total insured values (TIV) for each city of interest and policy class.

The analyst is interested to see that Miami has the highest TIV, despite having approximately half the population of Jacksonville. Based on these values, it seems like Jacksonville could be a good choice for expanding business. The analyst will also look closer at advertising and competition in Miami so she can create a strategy for the other cities.

The company believes it may be able to break into new markets by advertising bundle options to existing customers. The marketing team thinks it would be best to customize which bundles are promoted for each city based on which policy classes are being under-purchased. The analyst can determine which bundles to promote in each city by changing the numeric variable on the stacked bar chart from the sum of TIV to the count of policies and displaying the chart with a stacked percent. The changes to the chart allow the analyst to determine the proportions of policies sold from each class for the cities of interest.

The chart shows that most of the cities have at least one policy class with a very low percentage of the overall count of policies for the city. For example, Jacksonville and Saint Petersburg have no policies in the Automobile and Property classes, respectively. The company could try to increase the sales of those policy classes by advertising insurance bundles to existing life insurance customers, which make up a relatively high proportion of the policies in both Jacksonville and Saint Petersburg.

## Create a stacked bar chart

To create a stacked bar chart, complete the following steps:

1. Select one of the following data options:
• Two string fields
• Two string fields plus a number or rate/ratio field
##### Note:

If you do not select a number or rate/ratio field, your data will be aggregated and a count will be displayed.

You can search for fields using the search bar in the data pane.

2. Create the stacked bar chart.
1. Drag the selected fields to a new card.
2. Hover over the Chart drop zone.
3. Drop the selected fields on Stacked Bar Chart.
##### Tip:

You can also create charts using the Chart menu above the data pane or the Visualization type button on an existing card. For the Chart menu, only charts that are compatible with your data selection will be enabled. For the Visualization type menu, only compatible visualizations (including maps, charts, or tables) will be displayed.

## Usage notes

The Layer options button can be used to select data from the subgroup. To change the color associated with a category, click the symbol and choose a color from the palette, or enter a hex value.

The Appearance tab can be used to change the layout between Stacked count and Stacked percent. The Stacked count layout displays the numerical variable on the chart as totals for both the category and subcategory, with the length of the bar and segments inside the bar representing the amount of the numerical variable. The Stacked percent layout displays all categories as the same size, representing a range from 0 to 100%. The subcategories are all displayed as proportions of the bars. The Appearance tab can also be used to change the outline color.

The value of each bar can be symbolized as a count of features in each category on the y-axis, or as a number or rate/ratio field. If a field is used, the bar values can be calculated as a sum, minimum, maximum, average, percentile, or median of values from the field for each category.

##### Note:

The median and percentile statistics are not available for certain remote feature layers. If your remote feature layer does not support median or percentile, you can copy the layer to your workbook.

The subgroup can be removed to change the stacked bar chart to a bar chart.

Use the Chart statistics button to display the mean, median, upper quartile, lower quartile, or a custom value. Statistics are not available for charts using the Stacked percent layout.

Use the Sort button to sort the categorical data in either ascending or descending order by the numeric variable or alphabetically.

Use the Visualization type button to switch directly between a stacked bar chart and other visualizations, such as a summary table, heat chart, or chord diagram.

Use the Flip card button to view the back of the card. The Card info tab provides information about the data on the card, the Export image tab allows users to export an image of the card, and the Export data tab allows users to export the data from the card.

When you create a stacked bar chart, the result dataset with the string and number fields used to create the chart is added to the data pane. The result dataset can be used to find answers with nonspatial analysis using the Action button .