Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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.
Thanks,
SBC
Solved! Go to Solution.
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.
Hi @SBC
Please refer to attached sample file with the solution
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"
Hi @SBC
Please refer to attached sample file with the solution
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"
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
11 | |
10 | |
10 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |