如何在 Excel 数据透视表中添加计算字段
单击透视表,打开“数据透视表分析 > 字段、项和集 > 计算字段”,输入名称和用字段名写的公式,例如 =Revenue*10%。不要用工作表单元格地址。Google Sheets 没有同样的对话框,应在源数据中加辅助列 =F2*0.1,再把该列放入值区域。
本文目录
快速解答
单击透视表,打开“数据透视表分析 > 字段、项和集 > 计算字段”,输入名称和用字段名写的公式,例如 =Revenue*10%。不要用工作表单元格地址。Google Sheets 没有同样的对话框,应在源数据中加辅助列 =F2*0.1,再把该列放入值区域。
=24450*0.1
=9450*0.1
=19800*0.1检查要点
2026 年 11 月 12 日测试中,收入合计 24450 的 10% 为 2445,东区 9450 为 945,Widget 19800 为 1980。若透视表中的佣金与这些数字不符,可能是公式用错了字段,或值仍显示为计数。计算字段是先汇总再运算,比率类公式有时不合适,这时应在源表按行计算。
边界与兼容性
字段名含空格时要用单引号,例如 ='Unit Price'*Quantity。若按钮是灰色,可能选中的不是透视表,或数据来自数据模型,那时应添加度量而不是计算字段。“占总计的百分比”是显示选项,不必做成计算字段。改源数据后请刷新。
完整英文示例、公式与作者备注
Excel How-toTested in: The 10% commission figures below were evaluated in Google Sheets on 12 November 2026. Excel 365 menu names are the current desktop labels; I did not click through Fields, Items, & Sets in Excel this session.
If you do not have a pivot yet, start with How to Create a Pivot Table in Excel. This page is only about a field you compute from other pivot fields.
Add the field in Excel
- Click any cell inside the pivot table.
- Open the PivotTable Analyze tab (it may be labeled Options or Analyze in older Excel).
- Choose Fields, Items, & Sets > Calculated Field.
- In Name, type something like
Commission. - In Formula, enter
=Revenue*10%(or=Revenue*0.1). You can double-click a field in the list instead of typing the name. - Click Add, then OK.
The field shows up in the Values well. If it arrives as Count of Commission, switch it to Sum, as in pivot table shows count instead of sum.
On the eight-sale sample used elsewhere on this site, 10% of Revenue should follow the same cuts as Revenue itself. In Google Sheets on 12 November 2026:
=24450*0.1
=9450*0.1
=19800*0.1
Those returned 2445 (grand total), 945 (East), and 1980 (Widget). After you add the calculated field, the pivot’s Commission totals should match those figures. If they do not, the formula is using the wrong field, Values is still on Count, or a filter is hiding rows.
How the formula is written
Use field names, not cell addresses. =Revenue*0.1 is right; =F2*0.1 is not, because F2 is a worksheet cell, not a pivot field. Spaces in a field name need single quotes: ='Unit Price'*Quantity.
Excel calculates a calculated field on the aggregated totals, not on each source row and then summed. For =Revenue*0.1 that does not matter, because 10% of the sum is the sum of the 10%s. For a ratio such as =Profit/Revenue or =Revenue/Quantity, the field can be wrong: it will divide the summed profit by the summed revenue (which may be what you want) or, depending on the layout, not match a row-level margin you had in mind. When the math has to happen on every source row, add a helper column in the source (=G2/F2) and pivot that column.
You can also add a calculated field that subtracts two fields, for example =Revenue-Cost. Keep the result in Values as Sum, and check it against a sheet formula such as =SUM(F2:F9)-SUM(G2:G9).
Google Sheets, and when not to use a calculated field
Sheets pivot tables do not offer Calculated Field. Insert a column in the source:
=F2*0.1
fill it down, then add that column to Values as SUM. The same 2445 / 945 / 1980 checks apply.
A calculated field is the wrong tool for “show Revenue as a percent of the grand total.” That is a display option, covered in pivot table percentage of total. It is also the wrong tool when the source is in the data model: add a DAX measure there, not a calculated field.
If you change the source after adding the field, refresh the pivot. To edit or delete the field, go back to Calculated Field, pick it from the name list, and change the formula or click Delete.