Forum Discussion
Using Dynamic Formatting to convert seconds to hours, minutes and seconds
- Anonymous2 years ago
Hi, peterg0417
Based on your information, I create a sample table:
Then create a calculated column, try the following DAX:
Column = VAR TotalSeconds = [Latest Execution Time(ss)] VAR Hours = INT(TotalSeconds / 3600) VAR Minutes = INT(MOD(TotalSeconds, 3600) / 60) VAR Seconds = INT(MOD(TotalSeconds, 60)) VAR HoursText = IF(Hours > 0, Hours & "h ", "") VAR MinutesText = IF(Minutes > 0, Minutes & "m ", "") VAR SecondsText = IF(Seconds > 0, Seconds & "s", "") RETURN IF(TotalSeconds = 0, "0", TRIM(HoursText & MinutesText & SecondsText))Here is my preview:
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hI peterg0417 Considering you want to convert total seconds to hour, minutes, and seconds. Try below Codes:
Hope this helps!!
If this solved your problem, please accept it as a soltuion!!
Best Regards,
Shahariar Hafiz
I tried putting your code in as dynamic formatting but the error is still there. It looks like it's entering 2 digits (74 and 13, for the 2 lines) in between the correct value for seconds.
- shafiz_p2 years ago
Super User
If your time formatted measure is correctly evaluting then use that measure. Since don't know much about your data, it is hard to tell what exactly happening. If you have total seconds, then the provided measure should evalutes correctly.