英文:
Power BI : Find average per ID
问题
我是新手使用 PowerBI,我有这个表格:
所以简要解释一下:
- ID:表示任务执行的唯一ID
- DT_START:执行开始时间
- DT_END:执行结束时间
- ID_OBJECT:相关任务/计划的ID
- Duration:DT_START和DT_END之间的秒数
我想要添加一个新列或度量,不确定在这种情况下什么更好,其中包含每个ID_OBJECT的平均持续时间。所以,例如,对于出现在图片中的ID_OBJECT,我应该有一个包含此值的列(四舍五入为277):
我需要这个输出:
我尝试了一些解决方案,比如创建一个计算列:
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]
)
但我没有得到我需要的输出:
那么,最佳方法是什么?
谢谢。
英文:
I'm new to PowerBI and I have this table:
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):
I need this output :
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
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]) )
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论