The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello all,
I have firstly created two measures to calculate the overall time that some tasks takes.
1st measure: this calculate the overall TIME for 5 tasks (Measure's name = TimeActivities)
2nd measure: this calculate the time taken for the admin of one of the task and was calulated based on a separate data/table. (Measure's name = TimeActivities2 )
I now want to add the two TIME measures together to get an overall time, but somehow cannot do it. Could anyone advise ?
Just for note, both of the earlier measures follows this principle to get hh:mm:ss:
Solved! Go to Solution.
Hi @AntBI26 - To return time in hh:mm calculate the overall time by adding the times from timeactivity and timeactivitity2 and returning the result in the hh:mm
TotalTimeFormatted =
VAR TimeString1 = [TimeActivities]
VAR Hours1 = VALUE(LEFT(TimeString1, 2))
VAR Minutes1 = VALUE(MID(TimeString1, 4, 2))
VAR Seconds1 = VALUE(RIGHT(TimeString1, 2))
VAR TotalSeconds1 = (Hours1 * 3600) + (Minutes1 * 60) + Seconds1
VAR TimeString2 = [TimeActivities2]
VAR Hours2 = VALUE(LEFT(TimeString2, 2))
VAR Minutes2 = VALUE(MID(TimeString2, 4, 2))
VAR Seconds2 = VALUE(RIGHT(TimeString2, 2))
VAR TotalSeconds2 = (Hours2 * 3600) + (Minutes2 * 60) + Seconds2
VAR TotalSeconds = TotalSeconds1 + TotalSeconds2
VAR Hours = TRUNC(TotalSeconds / 3600)
VAR Minutes = TRUNC(MOD(TotalSeconds, 3600) / 60)
VAR Seconds = MOD(TotalSeconds, 60)
RETURN
FORMAT(Hours, "00") & ":" &
FORMAT(Minutes, "00") & ":" &
FORMAT(Seconds, "00")
Hope it works, please check
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
Thank you both, I impemented @rajendraongole1 solution, as it was easier to execute. Best wishes.
Hi @AntBI26 - To return time in hh:mm calculate the overall time by adding the times from timeactivity and timeactivitity2 and returning the result in the hh:mm
TotalTimeFormatted =
VAR TimeString1 = [TimeActivities]
VAR Hours1 = VALUE(LEFT(TimeString1, 2))
VAR Minutes1 = VALUE(MID(TimeString1, 4, 2))
VAR Seconds1 = VALUE(RIGHT(TimeString1, 2))
VAR TotalSeconds1 = (Hours1 * 3600) + (Minutes1 * 60) + Seconds1
VAR TimeString2 = [TimeActivities2]
VAR Hours2 = VALUE(LEFT(TimeString2, 2))
VAR Minutes2 = VALUE(MID(TimeString2, 4, 2))
VAR Seconds2 = VALUE(RIGHT(TimeString2, 2))
VAR TotalSeconds2 = (Hours2 * 3600) + (Minutes2 * 60) + Seconds2
VAR TotalSeconds = TotalSeconds1 + TotalSeconds2
VAR Hours = TRUNC(TotalSeconds / 3600)
VAR Minutes = TRUNC(MOD(TotalSeconds, 3600) / 60)
VAR Seconds = MOD(TotalSeconds, 60)
RETURN
FORMAT(Hours, "00") & ":" &
FORMAT(Minutes, "00") & ":" &
FORMAT(Seconds, "00")
Hope it works, please check
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
@AntBI26 , Try using below measure
OverallTime =
VAR TotalSeconds1 = SUMX('Sheet1', HOUR('Sheet1'[TimeOverall1]) * 3600 + MINUTE('Sheet1'[TimeOverall1]) * 60 + SECOND('Sheet1'[TimeOverall1]))
VAR TotalSeconds2 = SUMX('Sheet2', HOUR('Sheet2'[TimeOverall2]) * 3600 + MINUTE('Sheet2'[TimeOverall2]) * 60 + SECOND('Sheet2'[TimeOverall2]))
VAR TotalSeconds = TotalSeconds1 + TotalSeconds2
VAR Days = TRUNC(TotalSeconds / 3600 / 24)
VAR Hours = TRUNC((TotalSeconds - Days * 3600 * 24) / 3600)
VAR Minutes = TRUNC(MOD(TotalSeconds, 3600) / 60)
VAR Seconds = MOD(TotalSeconds, 60)
RETURN
IF((Hours + (Days * 24)) < 10, "0" & (Hours + (Days * 24)), (Hours + (Days * 24))) & ":"
& IF(Minutes < 10, "0" & Minutes, Minutes) & ":"
& IF(Seconds < 10, "0" & Seconds, Seconds)
Proud to be a Super User! | |
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the July 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
104 | |
76 | |
73 | |
47 |
User | Count |
---|---|
169 | |
113 | |
110 | |
83 | |
76 |