Group Data by Age for an Excel Pie Chart
Question details
Group records into age ranges and show the number of records in each range in a pie chart.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- The user has dates for items and wants to compare the proportions under one year, one to under two years, two to under three years, and three or more years old.
- Observed behavior
- The desired chart shows each age group as a share of the total number of valid records.
Make sure each record has a valid Excel date and that the source columns have headers. The examples below assume dates start in cell A2 and that columns B and C are available for age calculations.
Calculate Age Groups and Create a PivotChart in Excel
Use helper columns and a PivotTable to count records in each age range, then display the counts in a pie chart.
Enter the header Age in B1. In B2, enter =IF(OR(A2="",A2>TODAY()),"",DATEDIF(A2,TODAY(),"y")) and fill the formula down for all records.
Enter the header Age Group in C1. In C2, enter =IF(B2="","",IF(B2<1,"Under 1 year",IF(B2<2,"1 to under 2 years",IF(B2<3,"2 to under 3 years","3 or more years")))) and fill it down.
Select the source data, including headers and both helper columns. Choose Insert > PivotTable, select where to place it, and click OK.
In the PivotTable Fields pane, drag Age Group to Rows and the original date field to Values. If necessary, open Value Field Settings and select Count. Use the row filter to exclude blank age groups.
Click inside the PivotTable, choose Insert > PivotChart, select Pie, and click OK. Use Chart Elements to add data labels if needed.

Make an Age-Group Pie Chart in WPS Spreadsheet
Use helper formulas to group dates by age, count each group, and insert a pie chart in WPS Spreadsheet.
- 1. Open the data: Open your workbook in WPS Spreadsheet and check that the dates start in A2 and columns B and C are available.
- 2. Calculate ages and groups: Enter Age in B1 and Age Group in C1. Use the completed-years and age-group formulas from the solution above in B2 and C2, then fill both formulas down.
- 3. Build a summary: Enter the four age-group labels in E2:E5 exactly as they appear in column C. In F2, enter =COUNTIF($C:$C,E2) and fill the formula down to F5.
- 4. Insert a pie chart: Select E2:F5, choose Insert > Chart, and select a pie chart. Add a chart title or data labels using the chart options.

Frequently Asked Questions
What happens to a record on its first anniversary?
DATEDIF counts completed years, so the record moves from Under 1 year to 1 to under 2 years on its first anniversary.
Why are some records missing from the chart?
The formulas leave blank dates and future dates without an age group. Check the source dates and the PivotTable row filter, which excludes blank groups.
How do I update the pie chart when ages change?
Make sure Excel recalculates the formulas, then right-click the PivotTable and select Refresh. The linked PivotChart updates with the refreshed counts.
Can I show percentages on the pie chart?
Select the chart, open Chart Elements, and add Data Labels. In the label formatting options, select Percentage.




