How to sum multiple duration values that sum to greater than 24 hours in PowerBI

霸气de小男生 提交于 2019-12-13 03:21:08

问题


How do I sum multiple duration values (different people working in one day) when the results will be greater than 24 hours (e.g. 125:23:33) in a measure.

For example these are some duration values to add:

 13:33:55
 20:44:23
 15:31:11

回答1:


You will need to create a "New Quick Measure" column with the dax code below:

SumDuration = 

VAR TotalSeconds=SUMX('MyTable',HOUR('MyTable'[duration])*3600+MINUTE('MyTable'[duration])*60+SECOND('MyTable'[duration]))
VAR Days =TRUNC(TotalSeconds/3600/24)
VAR Hors = TRUNC((TotalSeconds-Days*3600*24)/3600)
VAR Mins =TRUNC(MOD(TotalSeconds,3600)/60)
VAR Secs = MOD(TotalSeconds,60)
return IF(DAYS=0,"",IF(DAYS>1,DAYS&"days ",Days&"day"))&IF(Hors<10,"0"&Hors,Hors)&":"&IF(Mins<10,"0"&Mins,Mins)&":"&IF(Secs<10,"0"&Secs,Secs)

After you get the SumDuration, you can apply Visual Level Filtering on your table (is less than - is more than) to show it or not on your front end.



来源:https://stackoverflow.com/questions/53762519/how-to-sum-multiple-duration-values-that-sum-to-greater-than-24-hours-in-powerbi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!