Power BI:按ID查找平均值

huangapple go评论85阅读模式
英文:

Power BI : Find average per ID

问题

我是新手使用 PowerBI,我有这个表格:

Power BI:按ID查找平均值

所以简要解释一下:

  • ID:表示任务执行的唯一ID
  • DT_START:执行开始时间
  • DT_END:执行结束时间
  • ID_OBJECT:相关任务/计划的ID
  • Duration:DT_START和DT_END之间的秒数

我想要添加一个新列或度量,不确定在这种情况下什么更好,其中包含每个ID_OBJECT的平均持续时间。所以,例如,对于出现在图片中的ID_OBJECT,我应该有一个包含此值的列(四舍五入为277):

Power BI:按ID查找平均值

我需要这个输出:

Power BI:按ID查找平均值

我尝试了一些解决方案,比如创建一个计算列:

AverageDuration = AVERAGEX(DISTINCT(SELECTCOLUMNS('EXECUTIONS', "ID_OBJ", [ID_OBJECT])), [Duration])

或者:

var id_obj = 'EXECUTIONS'[ID_OBJECT]

Return
AVERAGEX(
FILTER(ALL('EXECUTIONS'), 'EXECUTIONS'[ID_OBJECT] = id_obj), 'EXECUTIONS'[Duration]
)

但我没有得到我需要的输出:

Power BI:按ID查找平均值

那么,最佳方法是什么?

谢谢。

英文:

I'm new to PowerBI and I have this table:

Power BI:按ID查找平均值

So a bit of explanation:

  • ID : unique ID which represent a task's execution
  • DT_START : beginning of the execution
  • DT_END : end of the execution
  • ID_OBJECT : ID of the related task / plan
  • Duration : number of seconds between DT_START abd DT_END

I want to add a new column or measure not sure what's best in this case that contains the average of duration per ID_OBJECT. So for example with the ID_OBJECT that appears in the picture I should have a column with this value (rounded : 277):

Power BI:按ID查找平均值

I need this output :

Power BI:按ID查找平均值

I tried a few solutions like creating a calculated column with :

AverageDuration = AVERAGEX(DISTINCT(SELECTCOLUMNS('EXECUTIONS', "ID_OBJ", [ID_OBJECT])), [Duration]) 

Or :

var id_obj = 'EXECUTIONS'[ID_OBJECT]

Return
AVERGEX(
	FILTER(ALL('EXECUTIONS'), 'EXECUTIONS'[ID_OBJECT] = id_obj), 'EXECUTIONS'[Duration]
)

But I don't have the output I need

Power BI:按ID查找平均值

So what is the best way to achieve this.

Thanks.

答案1

得分: 2

尝试这个度量值

平均持续时间 = CALCULATE(AVERAGE('EXECUTIONS'[Duration]), ALLEXCEPT('EXECUTIONS', 'EXECUTIONS'[ID_OBJECT]))
英文:

Try this measure

AverageDuration = CALCULATE(AVERAGE('EXECUTIONS'[Duration]), ALLEXCEPT('EXECUTIONS', 'EXECUTIONS'[ID_OBJECT]) ) 

huangapple
  • 本文由 发表于 2023年7月13日 23:47:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76681251.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定