问题
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