July 3, 2022
Hi Everyone,
I'm looking for ideas to calculate the diference between the time values, at first in power query I calculated using the following by adding a cusotm coloumn.
Dhanil_0-1672921720572.png
The coloumn added in time format showed error, hence it was converted to whole numbers
Dhanil_2-1672921890586.png
Further the difference showing up in the matrix is not matching up to the actual difference
Dhanil_1-1672921813277.png
The time difference is not adding up, is there a measure or any menthod that can help me solve the issue ? - DATEDIFF is not showing up when I type in adding custom column
Moderators
January 31, 2022
Moderators
January 31, 2022
To calculate time spent in Power Query, first select the End time column, press control and then the Start time column. On the Add Column tab press the Time button and choose Subtract. This will generate the appropriate code that calculates duration for you. It may look something like this:
Table.AddColumn(#"Previous Step", "Time spent", each [End] - [Start], type nullable duration)
Don't use the Duration.Minutes function as it only returns the minutes portion of a duration. So, it the total duration was 3 hours 10 minutes, it returns the number 10. And you should not set the data type to Time as that will return an error, as you have noticed.
With regard to DATEDIF, that function does not exist in Power Query (M-code).
Moderators
January 31, 2022
Moderators
January 31, 2022
Not sure about what that columns represents, but I suspect that you are expressing the total number of minutes as a portion of a whole day, containing 1440 minutes.
3hrs, 19min = 199min / 1440 = 0.138894 = 0.14 rounded
2hrs, 18min = 138min / 1440 0.095833 = 0.10 rounded
Similarly, 7min / 1440 = 0.004861 = 0.00 rounded
1 Guest(s)