简体   繁体   English

计算数据透视表中的移动平均值

[英]Calculating the running average in a pivot table

I have a pivot table that has the following structure: Row fields are month (number 1 through 12) and values ( revenue , sqft , rev_per_sqft which is a calculated field). 我有一个具有以下结构的数据透视表:行字段是month (数字1到12)和valuesrevenuesqftrev_per_sqft ,这是一个计算字段)。 I also show the Running Total in based on the month row. 我还根据month行显示“ Running Total in

Now, this works perfectly for revenue and sqft . 现在,这非常适合revenuesqft

But it does not work for rev_per_sqft . 但是它不适用于rev_per_sqft The formula for the field is =revenue / sqft . 该字段的公式为=revenue / sqft It works on an individual monthly basis but when I do Running Total in it just sums up the monthly values instead of doing the average. 它按月单独工作,但是当我执行“ Running Total in它只是将每月值相加而不是取平均值。 I selected both sum as well as average and it doesn't make a difference. 我同时选择了总和和平均值,这没有区别。

Is there a way to show the average? 有没有办法显示平均值?

If this hasn't been completely clear yet, here is how my table looks like: 如果这还不是很清楚,这就是我的表格的样子:

+-------+----------------------+---------+
| Monat |        Werte         | Totals  |
+-------+----------------------+---------+
|     1 | Revenue              | 651.32  |
|       | sqft                 | 52.3    |
|       | Rev per sqft         | 12.45   |
|       | Running Revenue      | 651.32  |
|       | Running sqft         | 52.3    |
|       | Running rev per sqft | 12.45   |
|     2 | Revenue              | 476.17  |
|       | sqft                 | 87.21   |
|       | Rev per sqft         | 5.46    |
|       | Running Revenue      | 1127.49 |
|       | Running sqft         | 139.51  |
|       | Running rev per sqft | 17.91   |
+-------+----------------------+---------+

As you can see, the value for the Running rev per sqft starts to get distorted by the second month and continues to do so. 如您所见,“ Running rev per sqft正在Running rev per sqft的值在第二个月开始失真,并继续保持这种状态。

The difficulty you have run into is that you would like to be able to define a calculated field as (Running Total of Revenue)/(Running Total of SqFt) and there is no obvious way of doing this in your pivot table. 您遇到的困难是,您希望能够将计算所得的字段定义为(Running Total of Revenue)/(Running Total of SqFt)而在数据透视表中没有明显的方法。 Arithmetically. 算术。 as you have found, this gives very different results from the running total of your calculated field of Revenue/SqFt . 正如您所发现的,这与您所计算的Revenue/SqFt字段的总和产生了截然不同的结果。

One approach is to recast your pivot table so that it contains the monthly sums of Revenue and SqFt as columns along with their associated running totals. 一种方法是重新构建数据透视表,以使其包含RevenueSqFt的月总计作为列以及它们的关联运行总计。 You can then use this pivot table as the data source for a second pivot table. 然后,您可以将此数据透视表用作第二个数据透视表的数据源。 In this second pivot table you can now define two calculated fields: one based on the ratio of the monthly values and a second based on the ratio of the running total values. 在第二个数据透视表中,您现在可以定义两个计算字段:一个基于月度值的比率,另一个基于运行总值的比率。

The picture below illustrates: 下图说明:

使用另一个数据透视表作为数据源的数据透视表

This is a slightly clunky solution as any changes to the source data will require "Change Data Source" and "Refresh" operations to be undertaken on both pivot tables in the correct order. 这是一个笨拙的解决方案,因为对源数据进行的任何更改都将需要在两个数据透视表上以正确的顺序执行“更改数据源”和“刷新”操作。

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

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