The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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.
User | Count |
---|---|
16 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
8 | |
8 |