且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Excel数据透视表-计算总和的平均值

更新时间:2023-02-06 17:05:19

这是有效的解决方案:

首先,您应该安装或启用Power Pivot.引用Microsoft:

Firstly you should install or enable Power Pivot. Quoting Microsoft:

Power Pivot是一个Excel加载项,可用于执行强大的数据 分析并创建复杂的数据模型.

在较新的Excel版本中,已经安装了Power Pivot,您可以通过以下方法启用它:

In newer Excel versions Power Pivot is already installed and you can enable it by going to:

文件>选项>高级>数据>启用数据分析加载项:Power Pivot,Power View和Power Map

File > Options > Advanced > Data > Enable Data Analysis add-ins: Power Pivot, Power View, and Power Map

好的,现在您有了Power Pivot,并且可以看到Power Pivot选项卡.请按照以下步骤操作:

Alright, so you have Power Pivot now and you can see Power Pivot tab. Please follow the steps below:

  1. 选择数据,然后在Power Pivot选项卡上单击添加到数据模型"图标.
  2. 在Power Pivot窗口中添加一列,该列将计算不同数量的 数据中的人员. = DISTINCTCOUNT([person])为其命名,例如 "DistPersNo". 这是至关重要的一步– Power Pivot使您能够 计算所选列中的唯一值.
  3. 使用公式= [amount]/[DistPersNo]添加另一列,将其命名为 人均".
  4. 在Power Pivot窗口中,单击PivotTable并将新的数据透视表添加到 您的工作表.
  5. 在数据透视表中,将人员"添加到行中,并将数量"添加到值中.现在,如果您将"PersonAverages"添加到值(其总和)并过滤出资金"x1",您将获得所需的结果,即值1100.
  1. Select your data and click add to "data model" icon on Power Pivot tab.
  2. In Power Pivot window add column which will count distinct number of persons in the data. =DISTINCTCOUNT([person]) name it for example "DistPersNo". This is crucial step – Power Pivot enables you to count unique values in selected column.
  3. Add another column with formula =[amount]/[DistPersNo] name it "PersonAverages".
  4. In Power Pivot window click PivotTable and add new pivot table to your worksheet.
  5. In Pivot Table add 'persons' to rows and 'amount' to values. Now, if you add 'PersonAverages' to values (sum of it) and filter out fund 'x1' you will achieve desired result i.e. value of 1100.

希望有帮助.