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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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!:
Mastering Power BI 2nd Edition

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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