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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors