Forum Discussion
Calculating day/time difference
- 10 years ago
You can also add a custom column in Query Editor.
=Duration.ToText([AlarmClearedUTC]-[AlarmSentUTC])
And then in DAX
Column = IF ( LEFT ( Table1[Duration], IFERROR ( SEARCH ( ".", Table1[Duration] ), 1 ) - 1 ) = "", 0, LEFT ( Table1[Duration], IFERROR ( SEARCH ( ".", Table1[Duration] ), 1 ) - 1 ) ) & " DAY " & RIGHT ( Table1[Duration], 8 )Or Duration.ToRecord and expand?
Duration.ToRecord([AlarmClearedUTC]-[AlarmSentUTC])
In your Query Editor window, add a custom column with a formula of:
[AlarmSentUTC] - [AlarmClearedUTC]
This will result in a Duration field that you can then use the blog article I posted earlier to format into the format you want.
I would get a raw number for that column. Do I format it using this:
Hours = INT([Duration in Seconds]/3600)
Minutes = INT(MOD([Duration in Seconds],3600)/60)
Seconds = MOD(MOD([Duration in Seconds],3600),60)
H = IF(LEN([Hours])=1,CONCATENATE("0",[Hours]),CONCATENATE("",[Hours]))
M = IF(LEN([Minutes])=1,CONCATENATE("0",[Minutes]),CONCATENATE("",[Minutes]))
S = IF(LEN([Seconds])=1,CONCATENATE("0",[Seconds]),CONCATENATE("",[Seconds]))
- Eric_Zhang10 years agoMicrosoft Employee
You can also add a custom column in Query Editor.
=Duration.ToText([AlarmClearedUTC]-[AlarmSentUTC])
And then in DAX
Column = IF ( LEFT ( Table1[Duration], IFERROR ( SEARCH ( ".", Table1[Duration] ), 1 ) - 1 ) = "", 0, LEFT ( Table1[Duration], IFERROR ( SEARCH ( ".", Table1[Duration] ), 1 ) - 1 ) ) & " DAY " & RIGHT ( Table1[Duration], 8 )Or Duration.ToRecord and expand?
Duration.ToRecord([AlarmClearedUTC]-[AlarmSentUTC])
- Anonymous8 years agoNot applicable
This is exactly what I'm looking for, but it doesn't work in Direct Query mode, do you have any alternatives for that?
- Anonymous7 years agoNot applicable
Importing the data?
- SWI-Inc4 years agoRegular Visitor
My data doesnt contain any days, when i use this power BI won't move the ifo to the table because of the zero days.