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
heidibb
Helper IV
Helper IV

Duration Troubles

Hello,

I am working on a project around runs, the duration for each run in hh:mm:ss and the pace (duration/total miles). My data is being captured in a google sheet, where I have the column defined as duration and it is being entered as 0:25:00 for example for the total running time. 

When I pull the data in, it initially looks right and shows exactly how it shows within the google sheet, but when I apply and look at it in the data window, it's converted over to a decimal. I understand that this is showing as a portion of a day (where 25 minutes is about .01736 of a day), but I would like to keep the data so it shows as hh:mm:ss where I can then total up the total running time and the average pace per person, etc.

I have searched through the message board and I'm not seeing anything similar to this.

I should also say that I'm very new to Power BI and am using this project as my first to get familiar with the tool.

Thanks in advance!

1 ACCEPTED SOLUTION

@Vvelarde YES, this worked almost perfectly!! I had to make a couple tweeks, changing your semi-colons to commas and had to fix the minute & seconds sections to account for leading zeros when we have single digits (see bolded section). If you see anything off with this, let me know, but I can't thank you enough!!

 

 

DurationRUNNER =
VAR DurationRUNNER =
SUM ( RTB_Runs[Duration] )
RETURN
IF (
ROUNDDOWN ( DurationRUNNER, 0 ) > 1,
ROUNDDOWN ( DurationRUNNER, 0 ) * 24
+ HOUR ( DurationRUNNER )
& ":"
& (if(len(minute(DurationRUNNER)) > 1,minute(DurationRUNNER), "0" & minute(DurationRUNNER))
& ":"
& (if(len(second(DurationRUNNER)) > 1,second(DurationRUNNER), "0" & second(DurationRUNNER))
)),
FORMAT ( DurationRUNNER, "hh:mm:ss" )
)

 

View solution in original post

7 REPLIES 7
v-qiuyu-msft
Community Support
Community Support

Hi @heidibb,

 

In your scenario, you can change data type of the field as time, see:

 

w2.PNG

 

If you have any question, please feel free to ask.

 

Best Regards,
Qiuyun Yu

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

Thank you @v-qiuyu-msft! That helped with the format in my data, but it won't allow me to sum up the amount of time. It only allows me to count the number of rows per runner.

 

So for example, if Beth had the follow runs and durations in June, I want to sum up total Duration where the final result is 13 hours, 20 minutes, 23 seconds (as hh:mm:ss it would be 13:20:23).

 

Any thoughts?

 

DateRunsMilesDurationPace
5/31/2016130:26:000:08:40
6/1/2016150:42:000:08:24
6/3/2016150:42:000:08:24
6/4/2016191:17:000:08:33
6/5/2016150:42:000:08:24
6/7/2016140:34:000:08:30
6/8/2016150:44:000:08:48
6/10/2016140:37:000:09:15
6/11/2016170:59:000:08:26
6/12/2016161:10:000:11:40
6/13/2016150:43:000:08:36
6/15/2016150:42:000:08:24
6/17/2016140:34:000:08:30
6/18/2016181:09:000:08:38
6/19/2016160:56:000:09:20
6/20/2016150:43:000:08:36
6/21/2016150:40:430:08:09
Vvelarde
Community Champion
Community Champion

hi @heidibb

 

Create a measure:

 

Total-Duration = FORMAT(SUm(RUNS[Duration]);"HH:MM:SS")

 

is : SS (with no space)

 

 

 




Lima - Peru

Thank you @Vvelarde!! this is almost there! Final question, the column totals are calculating a bit weird. Everything else looks great, but not sure how to address the column totals

 

Capture.JPG

I realize the grand totals for both months are off by 48 hours each, so it seems once it passes increments of 24 hours, it's dropping off. is there a way to just continue to total the hours indefinitly? This is the aggregation as it shows in excel. trying to replicate in Power BI.

 

    
 56Grand Total
Anna0:56:004:06:025:02:02
Beth0:26:0012:54:4313:20:43
Brian0:29:008:07:208:36:20
Christian 0:33:550:33:55
Erin0:45:005:15:006:00:00
Heidi 3:32:033:32:03
Jeremy0:26:003:29:293:55:29
Jillian0:32:097:18:207:50:29
Josh0:25:506:55:007:20:50
Justin0:25:551:05:311:31:26
Michelle 3:16:303:16:30
Grand Total4:25:5456:33:5360:59:47
Vvelarde
Community Champion
Community Champion

 

Hi @heidibb

 

Try this measure (hope it works)

 

Duration-RUNNER =
VAR DurationRUNNER =
    SUM ( Runners[Duration] )
RETURN
    IF (
        ROUNDDOWN ( DurationRUNNER; 0 ) > 1;
        ROUNDDOWN ( DurationRUNNER; 0 ) * 24
            HOUR ( DurationRUNNER )
            ":"
            & (
                MINUTE ( DurationRUNNER ) & ":"
                    SECOND ( DurationRUNNER )
            );
        FORMAT ( DurationRUNNER; "hh:mm:ss" )
    )



Lima - Peru

@Vvelarde YES, this worked almost perfectly!! I had to make a couple tweeks, changing your semi-colons to commas and had to fix the minute & seconds sections to account for leading zeros when we have single digits (see bolded section). If you see anything off with this, let me know, but I can't thank you enough!!

 

 

DurationRUNNER =
VAR DurationRUNNER =
SUM ( RTB_Runs[Duration] )
RETURN
IF (
ROUNDDOWN ( DurationRUNNER, 0 ) > 1,
ROUNDDOWN ( DurationRUNNER, 0 ) * 24
+ HOUR ( DurationRUNNER )
& ":"
& (if(len(minute(DurationRUNNER)) > 1,minute(DurationRUNNER), "0" & minute(DurationRUNNER))
& ":"
& (if(len(second(DurationRUNNER)) > 1,second(DurationRUNNER), "0" & second(DurationRUNNER))
)),
FORMAT ( DurationRUNNER, "hh:mm:ss" )
)

 

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.