[英]Excel pivot table - average of calculated sums
I'm sure this is simple, but how do I get a pivot table to display an average for a calculated sum of fields? 我确信这很简单,但是如何获得数据透视表以显示计算的字段总数的平均值? In the simplified example, I've filtered out fund x1, and the pivot table is showing the sums of the remaining funds per person.
在简化示例中,我已过滤掉基金x1,数据透视表显示每人剩余资金的总和。 Now how do I get an average by person (so, manually calculated, 3300/3)?
现在我怎么被人平均(这样,手工计算,三分之三千三百)?
I tried using a calculated field, but cannot figure out how it will work because the denominator will change based on how many people will have the funds I'm filtering on. 我尝试使用计算字段,但无法弄清楚它是如何工作的,因为分母将根据有多少人拥有我正在过滤的资金而改变。 If I use the averaging inside the calculated field it goes back to averaging the funds.
如果我使用计算字段内的平均值,它会回到平均资金。
I tried putting the calculation outside the pivot table, and this works, but of course as I filter, my calculated field is no longer adjacent to the pivot table data, instead just floating off on the worksheet by itself. 我尝试将计算放在数据透视表之外,这是有效的,但当然,当我过滤时,我的计算字段不再与数据透视表数据相邻,而只是在工作表上自行浮动。
TIA. TIA。
Per request here is the field list - if I try adding an "average of amount" to the value box it averages the fund amounts, instead of the fund amount per person. 这里的每个请求是字段列表 - 如果我尝试在值框中添加“平均金额”,它会平均基金金额,而不是每人的基金金额。 :
:
Here is working solution: 这是工作解决方案:
Firstly you should install or enable Power Pivot. 首先,您应该安装或启用Power Pivot。 Quoting Microsoft:
引用微软:
Power Pivot is an Excel add-in you can use to perform powerful data analysis and create sophisticated data models.
Power Pivot是一个Excel加载项,可用于执行强大的数据 分析和创建复杂的数据模型。
https://support.office.com/en-us/article/Power-Pivot-Powerful-data-analysis-and-data-modeling-in-Excel-a9c2c6e2-cc49-4976-a7d7-40896795d045?ui=en-US&rs=en-US&ad=US https://support.office.com/en-us/article/Power-Pivot-Powerful-data-analysis-and-data-modeling-in-Excel-a9c2c6e2-cc49-4976-a7d7-40896795d045?ui=en-美国和RS = EN-US&AD = US
In newer Excel versions Power Pivot is already installed and you can enable it by going to: 在较新的Excel版本中,已安装Power Pivot,您可以通过以下方式启用它:
File > Options > Advanced > Data > Enable Data Analysis add-ins: Power Pivot, Power View, and Power Map 文件>选项>高级>数据>启用数据分析加载项:Power Pivot,Power View和Power Map
Alright, so you have Power Pivot now and you can see Power Pivot tab. 好吧,现在你有Power Pivot,你可以看到Power Pivot标签。 Please follow the steps below:
请按照以下步骤操作:
Hope that helps. 希望有所帮助。
I would add a helper column in column D to count unique customers. 我会在D列中添加一个辅助列来计算唯一客户。
This will flag each row in your data with a 1 if it is the first time a name appears in the column or zero otherwise. 如果名称第一次出现在列中,则会将数据中的每一行标记为1,否则为零。 The pivot table calculation will sum up the total value and divide by the total unique customers.
数据透视表计算将总计总值并除以总独特客户。
I'm assuming that you want the value to come in any pivot table and not in a cell calculated outside the pivot table as a formula. 我假设您希望值在任何数据透视表中,而不是在数据透视表外部计算的单元格中作为公式。
As a workaround you can use another pivot table, which takes the input as the original pivot table to find the average. 作为一种变通方法,您可以使用另一个数据透视表,它将输入作为原始数据透视表来查找平均值。
The second pivot table has data source as- E3:F5
or till whatever row you require. 第二个数据透视表的数据源为-E3
E3:F5
或直到您需要的任何行。
You'll have to refresh all so that the second pivot table reflects any changes in the filter of first pivot table. 您必须刷新所有内容,以便第二个数据透视表反映第一个数据透视表的过滤器中的任何更改。
I've hidden (or you can filter it out) the grand total in the first pivot table so that the average gives the average of the sum of the amounts. 我隐藏了(或者你可以过滤掉)第一个数据透视表中的总计,以便平均值给出金额总和的平均值。
Since you didn't mention how you are using the data, I will give a couple of options that could work. 由于您没有提到如何使用数据,因此我将提供一些可行的选项。
If you are the only user of the data or if someone else using the data is pivot table savvy you can use the following field list setups to switch data usage: 如果您是数据的唯一用户,或者使用数据的其他人是数据透视表,您可以使用以下字段列表设置来切换数据使用情况:
Sort by Fund (Note the Fund and Person in the Row labels section) 按基金排序(请注意基金和行标签部分中的人员)
and Sort by Person (Note the reversed position of Fund and Person in the Row labels section) 按人格排序(请注意行标签部分中基金和人员的反转位置)
To simplify the data, you can always minimize the main fields. 要简化数据,您始终可以最小化主要字段。
If you are distributing the pivot table to other people who aren't able or willing to modify the pivot table data, I would recommend setting up two separate pivot tables (using the same data source) with the same setups that I showed above. 如果您将数据透视表分发给其他无法或不愿意修改数据透视表数据的人,我建议您使用上面显示的相同设置设置两个单独的数据透视表(使用相同的数据源)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.