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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Nazeem81
Helper I
Helper I

Summarize column of datatype time

I have problems summarizing the values in a column (inloggad tid) showing time in format h:mm:ss, the total value is not coming correct.

 

I tried creating to new measures: 

Inloggad sum = MAXX(DISTINCT(Tiddata[ProjektDatumSäljare]);MAX(Tiddata[Inloggad tid]))

Inloggad tid sum = SUMX(DISTINCT(Tiddata[ProjektDatumSäljare]);[Inloggad sum])

 

I tried to use the new measure Inloggad tid sum but it s still not summarizing correctly. The measure Inloggad tid sum is of format Date Time.

 

When I tried this in Power Query in Excel it was working. When I created a pivot table and used the measure "Inloggad tid sum" I just changed the format of the values to [t]:mm:ss and the summary came correct.

 

How can this be solved in Power BI Desktop?

1 ACCEPTED SOLUTION

@Nazeem81,

Create the following measures in your table.

totalseconds= SUMX('Tiddata',HOUR('Tiddata'[CopyDuration])*3600+MINUTE('Tiddata'[CopyDuration])*60+SECOND('Tiddata'[CopyDuration]))

 

Measure = RIGHT ( "0" & INT ( [totalseconds] / 3600 ), 2 )
& ":"
& RIGHT (
"0"
& INT ( ( [totalseconds] - INT ([totalseconds] / 3600 ) * 3600 ) / 60 ),
2
)
& ":"
& RIGHT ( "0" & MOD ([totalseconds] , 3600 ), 2 )



Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Nazeem81
Helper I
Helper I

When I use code below the summary is showing correct value, for example 34days02:59:27. But I dont want to show the summary in days, I want to show total hours, minutes and seconds. Instead of  34days02:59:27 it should show 818:59:27

 

Anyone who can help me solve this?

 

newDuration =

VAR TotalSeconds=SUMX('Tiddata';HOUR('Tiddata'[CopyDuration])*3600+MINUTE('Tiddata'[CopyDuration])*60+SECOND('Tiddata'[CopyDuration]))

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)

@Nazeem81,

Create the following measures in your table.

totalseconds= SUMX('Tiddata',HOUR('Tiddata'[CopyDuration])*3600+MINUTE('Tiddata'[CopyDuration])*60+SECOND('Tiddata'[CopyDuration]))

 

Measure = RIGHT ( "0" & INT ( [totalseconds] / 3600 ), 2 )
& ":"
& RIGHT (
"0"
& INT ( ( [totalseconds] - INT ([totalseconds] / 3600 ) * 3600 ) / 60 ),
2
)
& ":"
& RIGHT ( "0" & MOD ([totalseconds] , 3600 ), 2 )



Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Nazeem81
Helper I
Helper I

Anyone, please?
Greg_Deckler
Super User
Super User

Can you share sample data so that I can try to recreate this?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi,

 

See link below dfor sample data. I Want to be able to summarize inloggad tid in Power BI deskptop. Picture below shows its not working for me to summarize when creating a new measure to be able to sum.

 

 

 

datatype time.PNGhttps://ufile.io/9rio2

 

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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