【问题标题】:Pivot Table considers duplicate elements for the average calculation数据透视表考虑重复元素进行平均计算
【发布时间】:2021-03-17 10:38:17
【问题描述】:

我有一个基于下表的数据透视表(带有数据模型)

Id  |  Time
 1  |  10
 1  |  10
 1  |  10
 2  |  2
 3  |  5
 3  |  5
 4  |  4
 5  |  8

我需要计算平均时间。

基于数据透视表计算的平均值为6.75 --> (10*3+2+5*2+4+8)/8

但是,我的预期结果是5.8 --> (10+2+5+4+8)/5

如何设置数据透视表以不考虑重复项?

请注意,我无法删除重复的行。

我尝试将 AVERAGEX : =AVERAGEX(VALUES('Range'[Id]);'Range'[Time]) 与 DAX 一起使用。

但我正面临这个问题:This formula is invalid or incomplete: 'Calculation error in measure 'Range'[475e7fe7-92b4-478c-bd5f-6e7c95df27d7]: A single value for column 'Time' in table 'Range' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.'.

提前谢谢你!

解决方案

=AVERAGEX(VALUES('Range'[Id]);CALCULATE(AVERAGE('Range'[Time])))

【问题讨论】:

  • 带公式=AVERAGE(INDEX(UNIQUE(A2:B9),0,2))
  • @JvdV 感谢您的评论。我同意这个公式。但是,我需要直接在数据透视表中进行度量,因为我将根据其他条件进行一些分组(这是下一步)。我对AVERAGEX 的使用不正确?
  • 我在问题中发布了解决方案!谢谢。
  • 没有什么可以阻止您自己发布问题的答案,而不是编辑问题。如果您这样做,将来可能会使其他人受益。
  • 2天后可以,我现在做不到。

标签: excel excel-formula pivot-table


【解决方案1】:

解决方案

=AVERAGEX(VALUES('Range'[Id]);CALCULATE(AVERAGE('Range'[Time])))

【讨论】:

    猜你喜欢
    • 2021-07-27
    • 1970-01-01
    • 2019-12-30
    • 1970-01-01
    • 1970-01-01
    • 2018-06-21
    • 2021-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多