简体   繁体   English

使用数据透视表上的名称计算平均值

[英]Calculating the average using names on a pivot table

I'm trying to have the pivot table calculate the average number of employees underneath each supervisor for a specific region.我试图让数据透视表计算特定区域的每个主管之下的平均员工人数。 However pivot tables are unable to average out text strings.然而,数据透视表无法平均化文本字符串。 In the example below, within one region I have 5 supervisors but they all have different numbers of employees under them, some have 1 or 2. But all together there are 7 employees for that region.在下面的示例中,在一个区域内,我有 5 个主管,但他们下属的员工数量不同,有些有 1 或 2 个。但该区域总共有 7 名员工。 I need it to average out the number of employees per supervisor: so 7/5 = 1.4 would be the average.我需要它来平均每个主管的员工人数:所以 7/5 = 1.4 将是平均值。 Is there any way you can create a count of employee divided by the amount of unique supervisors using a pivot table?有什么方法可以创建员工人数除以使用数据透视表的唯一主管人数?

Number of Supervisor to Employee监事对员工人数

OK well not very elegant I know but this would do it.好吧,我知道不是很优雅,但这会做到。 Add a helper column which works out the fraction of a supervisor available to each employee (eg 2 employees per supervisor = 1/2, 3 employees = 1/3 etc.) starting in D2:-添加一个辅助列,用于计算从 D2 开始的每个员工可用的主管的比例(例如,每个主管 2 名员工 = 1/2,3 名员工 = 1/3 等):-

=1/COUNTIFS($A$2:$A$20,A2,$C$2:$C$20,C2)

Then you can put the sum of these and the count of any column into a pivot table, putting Region as the row variable, and simply a manual formula to work out the ratio starting in J2:-然后,您可以将这些总和和任何列的计数放入数据透视表中,将 Region 作为行变量,并简单地手动计算从 J2 开始的比率:-

=IFERROR(I2/H2,"")

在此处输入图片说明

Note:- You can use GetPivotData to get the totals from the pivot table if you prefer.注意:- 如果您愿意,可以使用 GetPivotData 从数据透视表中获取总计。 You could also use an array formula to list the distinct values of Region and not use a pivot table, but the pivot is quicker.您还可以使用数组公式列出 Region 的不同值而不使用数据透视表,但数据透视表更快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM