如何正确地汇总数据透视表中带有计算字段的汇总字段

吉索尔

我有一个带有日期的表,以及两个值列,项目1和项目2。

示例Excel数据表

我想打一个数据透视表的最大月度出口值Item 1Item 2

这按预期工作。然后,我想对这些最大值求和,以得到数据透视表中第1项和第2项的最大值的总和。

我试过使用两个计算字段:

=SUM(MAX(' Item 1'), MAX(' Item 2'))=SUM('Item 1','Item 2')

但这个数额从当月的所有值Item 1Item 2,不仅最大值。使用数据透视表外部的公式很容易,但是我想在数据透视表内部执行此操作,以便将来可以对其进行图表绘制并添加新数据。下图显示了上述两个计算字段的结果(红色),以及数据透视表外部的简单公式,给出了所需的结果(绿色)。

结果数据透视表和所需结果

我正在Windows 10上使用Excel Professional Plus2016。如果要尝试,请使用以下示例数据。

Date    Item 1  Item 2
01/01/2020  2   8
02/01/2020  3   6
03/01/2020  5   4
04/01/2020  3   7
05/01/2020  5   4
06/01/2020  2   7
07/01/2020  3   4
01/02/2020  7   6
02/02/2020  3   4
03/02/2020  6   3
04/02/2020  3   7
05/02/2020  2   8
06/02/2020  5   7
07/02/2020  5   3
01/03/2020  3   8
02/03/2020  5   6
03/03/2020  7   3
04/03/2020  8   7
05/03/2020  3   4
06/03/2020  2   2
07/03/2020  5   5
Bu Luno

I suspect the plain pivot table function in excel is not enough to compute the min() and max() in a certain pivot table set, since the min() and max() functions are supposed to work in a row-by-row basis only. You need to create a "measure" (e.g. max of a certain group of cells, you may say they are calculated fields which can be manipulated more) to tell excel the expression to compute the value for a group of cells for you. This does not seems to work in plain old pivot table.

However, this functionality is provided in PowerPivot within MsExcel, which is using the DAX expression to create "measures" (simular to calculated fields but can be manipulated with DAX functions). Normally this addin is not enabled, so you need to enable it in COM-addin.

If you are using MSOffice 2013 or above, you can enable the PowerPivot Addin in File >> Options, select COM-addin and then Go, and then use the additional functions in the PowerPivot module for your needs.

https://support.office.com/en-us/article/start-the-power-pivot-add-in-for-excel-a891a66d-36e3-43fc-81e8-fc4798f39ea8

After enabling Powerpivot addin, you can create a new measure MaxItem1 using the maxx(datatable, datatable[item1]). then you can use this MaxItem1 measure to do sum(). You may need to use sumx(datatable, datatable[MaxItem1]+datatable[MaxItem2]).

Similarly minx() can be used to create MinItem values.

You may refer to this 5-min video for how to operate in Powerpivot. This video is not actually using the sum() function. You can look into sumx() to craft that precise function as above, which is not hard.

https://www.youtube.com/watch?v=lE2OAPh-Zf8

(我不知道在这个论坛中是否允许引用视频,如果我做错了什么,任何主持人都请纠正我。不幸的是,我目前使用的Excel是2010年,我无法创建XLS文件供您参考直接。但是我想视频很清晰,而且很容易做。)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

数据透视表中的计算列汇总未正确显示

来自分类Dev

如何将计算字段添加到 MS Access 中的汇总数据

来自分类Dev

如何在Elasticsearch中按字段汇总数据?

来自分类Dev

数据透视表中计算字段的总数?

来自分类Dev

R从带有时间字段的日期开始按小时汇总数据帧

来自分类Dev

oracle中如何根据日期汇总数据库字段值

来自分类Dev

如何从汇总数据中预先计算Alpha水平?

来自分类Dev

汇总数据表中的数据

来自分类Dev

如何从 Hyperledger 结构块生成数据透视表数据(汇总数据)

来自分类Dev

Python 3.6:创建数据透视表,汇总数据帧中多个列的值计数

来自分类Dev

属性汇总/计算字段

来自分类Dev

数据透视表中重叠分组的汇总

来自分类Dev

如何从java折叠数据透视表中的所有字段?

来自分类Dev

总计不正确显示数据透视表的计算字段

来自分类Dev

在其他汇总计算中包括汇总字段

来自分类Dev

如何正确获取这些字段的汇总

来自分类Dev

汇总数据表

来自分类Dev

数据透视表中的计算字段子总计未显示正确值

来自分类Dev

Python使用熊猫中的循环有效地汇总数据

来自分类Dev

从汇总数据中取样

来自分类Dev

如何正确地将 blob 数据插入表中

来自分类Dev

如何从非嵌套数据(BigQuery 中的 Google Analytics 数据)返回正确的汇总总数

来自分类Dev

如何在python中每周明智地滚动汇总数据?

来自分类Dev

汇总数据以计算R中的答案

来自分类Dev

数据透视表的计算字段总计

来自分类Dev

在数据透视表中添加计算字段并引用数据透视表的单元格

来自分类Dev

如何使用汇总功能计算网格中的总数

来自分类Dev

过滤后汇总数据表中的隐藏列

来自分类Dev

如何使用Oracle SQL汇总/数据透视表

Related 相关文章

  1. 1

    数据透视表中的计算列汇总未正确显示

  2. 2

    如何将计算字段添加到 MS Access 中的汇总数据

  3. 3

    如何在Elasticsearch中按字段汇总数据?

  4. 4

    数据透视表中计算字段的总数?

  5. 5

    R从带有时间字段的日期开始按小时汇总数据帧

  6. 6

    oracle中如何根据日期汇总数据库字段值

  7. 7

    如何从汇总数据中预先计算Alpha水平?

  8. 8

    汇总数据表中的数据

  9. 9

    如何从 Hyperledger 结构块生成数据透视表数据(汇总数据)

  10. 10

    Python 3.6:创建数据透视表,汇总数据帧中多个列的值计数

  11. 11

    属性汇总/计算字段

  12. 12

    数据透视表中重叠分组的汇总

  13. 13

    如何从java折叠数据透视表中的所有字段?

  14. 14

    总计不正确显示数据透视表的计算字段

  15. 15

    在其他汇总计算中包括汇总字段

  16. 16

    如何正确获取这些字段的汇总

  17. 17

    汇总数据表

  18. 18

    数据透视表中的计算字段子总计未显示正确值

  19. 19

    Python使用熊猫中的循环有效地汇总数据

  20. 20

    从汇总数据中取样

  21. 21

    如何正确地将 blob 数据插入表中

  22. 22

    如何从非嵌套数据(BigQuery 中的 Google Analytics 数据)返回正确的汇总总数

  23. 23

    如何在python中每周明智地滚动汇总数据?

  24. 24

    汇总数据以计算R中的答案

  25. 25

    数据透视表的计算字段总计

  26. 26

    在数据透视表中添加计算字段并引用数据透视表的单元格

  27. 27

    如何使用汇总功能计算网格中的总数

  28. 28

    过滤后汇总数据表中的隐藏列

  29. 29

    如何使用Oracle SQL汇总/数据透视表

热门标签

归档