Forum Discussion
Anonymous
5 years agoNot applicable
Show Duration Based on Time Spent
I am using an Excel table that has a Time Spent column formatted as Custom h:mm:ss. When I pull this into PowerBI, and I try to show the total duration using the Card visual, I get the following r...
- Anonymous5 years ago
Hi Anonymous ,
You can use measure.
The calculated column will not change according to the selection of the slicer.
1. Create measure.
SumTime_meausre = VAR TotalSeconds = SUMX( 'IT Productivity Measurements', HOUR( 'IT Productivity Measurements'[Time Spent] ) * 3600 + MINUTE( 'IT Productivity Measurements'[Time Spent] ) * 60 + SECOND( 'IT Productivity Measurements'[Time Spent] ) ) 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)2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
selimovd
5 years agoMost Valuable Professional
Hey Anonymous ,
make sure the column you mention is in the format time:
Then you can use the solution from that post to calculate the duration:
SumTime =
VAR TotalSeconds =
SUMX(
'Table Name',
HOUR( 'Table Name'[Column] ) * 3600
+ MINUTE( 'Table Name'[Column] ) * 60
+ SECOND( 'Table Name'[Column] )
)
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)
If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
Best regards
Denis
Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic
- Anonymous5 years agoNot applicable
Thank you both for the feedback. I now have the following, which the totals don't change when selecting different technicians.