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

Duration for more than 24h with DAX

Hey guys.

 

i have the straight distance between two coordinates and i'd like to calculate, with a average speed of 80km/h, the travel time between them.

 

the problem is that some routes take more than 24h to be completed and then i stumble on the 'hour' formatting, that keeps me from getting the 'duration' correctly.

 

for example:

 

my current travel time formula: travel = TABLE[distance]/80/24

 

so, 2000(distance)/80(avg km/h)/24(turn into a 'valid decimal' to convert to datetime) returns 1,041666 (one day and one hour), but only show 01:00:00 (should be 25:00:00).

 

how can i proceed with that?

 

IMPORTANT! I need that only with DAX, sadly.

 

 

 

 

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

For your scenario, I suggest you could calculate the seconds first and then translate the seconds to HH:MM:SS.

 

seconds = 'Table1'[Distance]/80*3600

 

To translate the seconds to HH:MM:SS, you could refer to this blog Aggregating Duration/Time.

 

Here is my test result.

 

translate to hhmmss.PNG

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
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

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

For your scenario, I suggest you could calculate the seconds first and then translate the seconds to HH:MM:SS.

 

seconds = 'Table1'[Distance]/80*3600

 

To translate the seconds to HH:MM:SS, you could refer to this blog Aggregating Duration/Time.

 

Here is my test result.

 

translate to hhmmss.PNG

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you sooooooooooo much, i was struggling to get this done. Cat LOL

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.