Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Akhil008
Regular Visitor

Incorrect Total time in hh:mm:ss Format

I'm trying to calculate the sum of time using the below formula but unable to get the desired result because the dax is not able to convert 00:00:00 to 12:00:00. I even tried converting the column to the 12hr format but still unable to achieve the result.

 

Formula:

 Login=

var TotalTime=SumX(

data,

hours(data[logintime]) + Divide(minute(data[logintime]),60) +Divide(second(data[logintime]),3600) )

var days=Divide(TotalTime,24)

var Hours=(days)*24

var HoursInt=Trunc(Hours)

var Minutes=(Hours - HoursInt)*60

var MinutesInt=Trunc(Minutes)

var Seconds=Round ((Minutes-MinutesInt)*60,0)

Return

Format(HoursInt,"00")&"h,"& Format(MinutesInt, "00")&"m,"&Format(Seconds, "00")&"s"

 

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Akhil008 
Why do you want to sum the time? What does that mean?

Hi, I want to calculate the total login time for the agents. I have a column that have login time in seconds and I've transformed the  column in hh:mm:ss and now I want the sum of hours ,minutes and seconds in the format hh:mm:ss

@Akhil008 
Please try

Login =
VAR TotalSeconds = 263117
VAR Seconds =
    MOD ( TotalSeconds, 60 )
VAR TotalMinutes =
    QUOTIENT ( TotalSeconds, 60 )
VAR Minutes =
    MOD ( TotalMinutes, 60 )
VAR TotalHours =
    QUOTIENT ( TotalMinutes, 60 )
VAR Hours =
    MOD ( TotalHours, 24 )
VAR Days =
    QUOTIENT ( TotalHours, 24 ) -- just in case required
RETURN
    FORMAT ( Hours, "00" ) & "h,"
        & FORMAT ( Minutes, "00" ) & "m,"
        & FORMAT ( Seconds, "00" ) & "s"

@Akhil008 

Sorry did not clarify the solution. The integer in the TotalSeconds variable shall be simply replaced with sum of the time in seconds column. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.