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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
SBC
Helper III
Helper III

calculate Turn-around-time based on two column values

Hi 

How to calculate the duration of date and time in one column in power bi. 

example:

base on indate and outdate column, duration column  need to  be calculated.

SBC_0-1663311669699.png

 

 

Thanks,

SBC

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

You can easily do this in Power Query, which is the most suitable for this kind of task. Create a custom columns and insert the following formula:

 

 

Duration.TotalMinutes([InDat]-[outDate])

 


EDIT: You can then use this other formula to obtain the hours format:

 

=Number.From([Duration_Column])*24

 

Since you asked for this in DAX, I feel like I should also point out how to help you with DAX. Power Query remains the best tool, but in case here is what you can use with DAX:

DATEDIFF ( Table[inDat], Table[outDate], SECOND )

 

This will give you the duration in seconds, you can pick other parameters as you prefer, of course.

View solution in original post

tamerj1
Super User
Super User

Hi @SBC 
Please refer to attached sample file with the solution 

1.png

Duration = 
VAR Period = DATEDIFF ( 'Table'[InDate], 'Table'[OutDate], SECOND )
VAR Days = QUOTIENT ( Period, 86400 )
VAR Hours = QUOTIENT ( Period, 3600 ) - Days * 24
VAR Minutes = QUOTIENT ( Period, 60 ) - Days * 1440 - Hours * 60
VAR Seconds = Period - Days * 86400 - Hours * 3600 - Minutes * 60
RETURN
    Days & " days : " & Hours & " hrs : " & Minutes & " mins : " & Seconds & " secs"

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @SBC 
Please refer to attached sample file with the solution 

1.png

Duration = 
VAR Period = DATEDIFF ( 'Table'[InDate], 'Table'[OutDate], SECOND )
VAR Days = QUOTIENT ( Period, 86400 )
VAR Hours = QUOTIENT ( Period, 3600 ) - Days * 24
VAR Minutes = QUOTIENT ( Period, 60 ) - Days * 1440 - Hours * 60
VAR Seconds = Period - Days * 86400 - Hours * 3600 - Minutes * 60
RETURN
    Days & " days : " & Hours & " hrs : " & Minutes & " mins : " & Seconds & " secs"
Anonymous
Not applicable

You can easily do this in Power Query, which is the most suitable for this kind of task. Create a custom columns and insert the following formula:

 

 

Duration.TotalMinutes([InDat]-[outDate])

 


EDIT: You can then use this other formula to obtain the hours format:

 

=Number.From([Duration_Column])*24

 

Since you asked for this in DAX, I feel like I should also point out how to help you with DAX. Power Query remains the best tool, but in case here is what you can use with DAX:

DATEDIFF ( Table[inDat], Table[outDate], SECOND )

 

This will give you the duration in seconds, you can pick other parameters as you prefer, of course.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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