简体   繁体   English

需要求pivot表中所有值的平均值

[英]Need to find the average of all values in pivot table

I have a data.table that is pulling all successful contacts by case manager over a period of time.我有一个 data.table,它在一段时间内通过个案经理拉取所有成功的联系人。 We've created a pivot table of the data that groups by case manager for the rows and by month of the contact for the columns.我们创建了一个 pivot 数据表,该表按行的个案经理和列的联系人月份进行分组。 It counts the appointment IDs to get counts per case manager per month.它计算约会 ID 以获取每个案例经理每月的计数。

My manager wants this data displayed in a chart to easily visualize the data.我的经理希望将此数据显示在图表中以便轻松可视化数据。 The part I can't get is she wants the average contacts per month over all the case managers and all the months to be displayed on the chart.我无法得到的部分是她希望所有个案经理和所有月份的每月平均联系人显示在图表上。 Essentially, she wants the average of all the values in the pivot table.本质上,她想要 pivot 表中所有值的平均值。

I've played around with power pivot and the DAX functions averagex() and summarize() to get averages in the total row per column, but the ultimate grand total is still the average of the totals.我玩过 power pivot 和 DAX 函数 averagex() 和 summarize() 以获得每列总行的平均值,但最终的总计仍然是总计的平均值。

How can I get the average of all the fields by itself?我怎样才能自己得到所有字段的平均值?

Here is the sample pivot table with the totals per case manager per month这是示例 pivot 表,其中包含每个案例经理每月的总数

数据透视表

Here are the totals using averagex(summarize()) to get counts for the values and average for the totals.以下是使用 averagex(summarize()) 获取值计数和总计平均值的总计。

AVERAGEX ( SUMMARIZE ( Table1, [Caseload], "x", COUNTA ( [Client ID] ) ), [x] )

However, the real average I want to see is 34 (all the values averaged together然而,我想看到的真正的平均值是 34(所有值一起平均

总计

You need to summarize by month as well to be able to average the way you want.您还需要按月进行汇总,以便能够按照您想要的方式进行平均。

avg_count =
AVERAGEX (
    SUMMARIZE (
        Table1,
        Table1[Caseload], --Assuming this is what you have on the rows
        Table1[Month],    --Assuming this is what you have on the columns
        "x", COUNTA ( Table1[Client ID] )
    ),
    [x]
)

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

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