How to Create a Stacked Bar Chart for Value Counts of 1, 2, and 3
Question details
The user needs to summarize a column containing the values 1, 2, and 3, and visualize the counts as a stacked bar chart with different colors for each value segment.

- Product
- Spreadsheets
- Device & OS
- not provided
- Scenario
- Visualizing the frequency of specific numeric values from a dataset into a single stacked bar format for quick comparison.
- Observed behavior
- The goal is to generate a summary table counting the occurrences of 1, 2, and 3, and then produce a stacked bar chart reflecting these counts with custom segment colors like green, blue, and yellow.
Ensure your dataset is organized in a single column without empty rows interrupting the data, and locate a blank area in your worksheet to create the necessary summary table.
Use COUNTIF Formulas and Insert a Stacked Bar Chart
Create a summary table to calculate the frequency of each value using the COUNTIF function, then use this structured data to generate and format a stacked bar chart.
A stacked bar chart requires aggregated data to display segments correctly. By using the COUNTIF function, you can automatically calculate how many times each specific value appears in your dataset, creating the perfect foundation for your chart.
Set up a new table in your worksheet. Dedicate one row for your data source and create separate columns with headers for the values 1, 2, and 3.
In the cell under the header '1', enter the formula =COUNTIF(A:A,1) (assuming your raw data is in column A). Repeat this process for '2' with the formula =COUNTIF(A:A,2) and for '3' with =COUNTIF(A:A,3).
Select your newly created summary table, including the headers. Go to the 'Insert' tab on the top ribbon, click on 'Bar Chart', and select the 'Stacked Bar' option.
Click on individual chart segments to select a specific data series. Right-click and choose 'Format Data Series' to change the fill color. For example, set the segment for 3 to green, 2 to blue, and 1 to yellow.

Create Professional Stacked Bar Charts in WPS Spreadsheet
WPS Spreadsheet provides powerful data analysis tools, including the COUNTIF function and a wide variety of customizable charts. Easily summarize your data and create stunning stacked bar charts to visualize value distributions seamlessly.
- 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open your spreadsheet containing the column of raw values.
- 2. Apply the COUNTIF function: Set up a summary table horizontally and use the =COUNTIF() formula to count the occurrences of 1, 2, and 3.
- 3. Insert Stacked Bar Chart: Highlight the summary table, navigate to the Insert tab, click Chart, and select the Stacked Bar chart type.
- 4. Customize Colors: Double-click the chart segments to open the formatting pane on the right and apply your preferred custom colors to each series.

Frequently Asked Questions
Can I use this method for text values instead of numbers 1, 2, and 3?
Yes. The COUNTIF function works perfectly with text criteria. Simply replace the number in the formula with your text enclosed in quotation marks, such as =COUNTIF(A:A,"Completed").
Why is my stacked bar chart showing multiple separate columns instead of a single stacked bar?
This usually happens if your summary table is oriented vertically instead of horizontally. Ensure your values (1, 2, 3) are set as column headers across a single row. Alternatively, you can click 'Switch Row/Column' in the Chart Design tab to fix the orientation.
How can I add data labels to show the exact count on each color segment?
Click on your stacked bar chart to select it, then click the '+' (Chart Elements) icon that appears next to the chart. Check the box for 'Data Labels' to display the numerical counts inside each colored segment.
Will the COUNTIF formula work if I have empty cells in my data column?
Yes, the COUNTIF formula specifically targets the exact criteria you set (such as 1, 2, or 3) and will automatically ignore any blank cells in the referenced column.




