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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

The sum of time is not showing correctly

Good day

 

I need help. I wrote a dax measure for calculating the total abseteesm time. The challenge i'm having is that when i display it is show less time where as i know that the total time should be a huge number.

 

E.g. instead of showing  1770:30:00 it displays 3:23:00 as the total time.

 

I don't know if it is a format or settings issue in power bi desktop.Capture.PNG

2 ACCEPTED SOLUTIONS
Nolock
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

first of all, Power BI doesn't support duration data type, just time. Therefore I don't think so it is a good idea to sum up time values. Convert your times into count of minutes, sum them up and convert them back.

Then formating with "HH:mm:ss" is also not a good idea because it just take the part of a day, not a total count of hours.

 

Calculate minutes (or even seconds if needed) of every time, sum it up and format the result as you need.

Sum of minutes formatted =
VAR sumOfMinutes =
    SUMX ( Table3; HOUR(Table3[Column1]) * 60 + MINUTE(Table3[Column1]) )
VAR totalHours = sumOfMinutes / 60
VAR minutes =
    MOD ( sumOfMinutes; 60 )
VAR formattedResult =
    FORMAT ( totalHours; 00 ) & ":"
        & FORMAT ( minutes; "00" )
RETURN
    formattedResult

Capture5.PNG

View solution in original post

Hi @Anonymous,

 

if it is ok for you and your question has been answered, please mark the answer as a solution.

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

Tough to say without data or at least calculations. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Nolock
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

first of all, Power BI doesn't support duration data type, just time. Therefore I don't think so it is a good idea to sum up time values. Convert your times into count of minutes, sum them up and convert them back.

Then formating with "HH:mm:ss" is also not a good idea because it just take the part of a day, not a total count of hours.

 

Calculate minutes (or even seconds if needed) of every time, sum it up and format the result as you need.

Sum of minutes formatted =
VAR sumOfMinutes =
    SUMX ( Table3; HOUR(Table3[Column1]) * 60 + MINUTE(Table3[Column1]) )
VAR totalHours = sumOfMinutes / 60
VAR minutes =
    MOD ( sumOfMinutes; 60 )
VAR formattedResult =
    FORMAT ( totalHours; 00 ) & ":"
        & FORMAT ( minutes; "00" )
RETURN
    formattedResult

Capture5.PNG

Anonymous
Not applicable

Can you help me to convert my entier value in to hh:mm:ss . right now i checked your variable and it worked and need to convert in to second 

Anonymous
Not applicable

Hi @Nolock,

 

Thank you so much for your help.

I have then decided to just display the sum of total hours as whole number.

 

 

Hi @Anonymous,

 

if it is ok for you and your question has been answered, please mark the answer as a solution.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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