DAX formula to convert time HH:MM:SS into decimal time mm.ss

IwannaBeLikeU

New Member
Joined
Nov 29, 2016
Messages
11
Call center data - due to the number of records, I'm importing call data into Access and setting the time field type to "date with time" and displaying hh:mm:ss. When I import this data into PowerPivot for Excel consumption, I create a pivot table and try to average the time data, but I get an error message due to the type of data. So now I'm thinking I'll convert the HH:MM:SS to seconds, but I'm having an issue with the DAX formula.
"=HOUR('Contact_History 18'[Handle Time])*3600+minute('Contact_History 18'[Handle Time]*60)+Second('Contact_History 18'[Handle Time])"

For 00:08:10 I get a result of 20.00 (That should say 490 seconds)

Any help on this matter would be greatly appreciated.
DAX issue with time.JPG
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
In Excel, the value of a displayed time of 00:08:10 which LOOKS like 8 minutes 10 seconds using the format hh:mm:ss, is shown in the Formula Bar as 12:08:10 AM, and has an actual value of 0.005671296 with the General format.
When brought into Power Query, it has to be defined as a Duration type to display as 0.00:08:10. When that's brought into the Data Model, there is no format available for Duration. The only data values available are Text, Date, Decimal Number, Whole Number, and Currency (Decimal Number with only two decimal places).
Your equation would work fine in Excel
Excel Formula:
=HOUR([@[Handle Time]])*3600+MINUTE([@[Handle Time]])*60+SECOND([@[Handle Time]])
, as well as in Power Query
Power Query:
= Table.AddColumn(#"Changed Type", "PQ Seconds", each Duration.Hours([Handle Time] ) * 3600 + Duration.Minutes([Handle Time])*60 + Duration.Seconds( [Handle Time] ))
but simply cannot be done in the Data Model.
I'd like to see the Power Pivot toolbar above with a cell in Handle Time selected to see what it's determining it is.
 
Upvote 0
Solution
In Excel, the value of a displayed time of 00:08:10 which LOOKS like 8 minutes 10 seconds using the format hh:mm:ss, is shown in the Formula Bar as 12:08:10 AM, and has an actual value of 0.005671296 with the General format.
When brought into Power Query, it has to be defined as a Duration type to display as 0.00:08:10. When that's brought into the Data Model, there is no format available for Duration. The only data values available are Text, Date, Decimal Number, Whole Number, and Currency (Decimal Number with only two decimal places).
Your equation would work fine in Excel
Excel Formula:
=HOUR([@[Handle Time]])*3600+MINUTE([@[Handle Time]])*60+SECOND([@[Handle Time]])
, as well as in Power Query
Power Query:
= Table.AddColumn(#"Changed Type", "PQ Seconds", each Duration.Hours([Handle Time] ) * 3600 + Duration.Minutes([Handle Time])*60 + Duration.Seconds( [Handle Time] ))
but simply cannot be done in the Data Model.
I'd like to see the Power Pivot toolbar above with a cell in Handle Time selected to see what it's determining it is.
DAX issue with time2.JPG
 
Upvote 0
Saw the first post.
What is the source of the data?
The data comes from an SQL BD, but I can only export that one week at a time into excel (400k rows of data). That gets compiled into access so I can get YTD records, and then I connect PowerPivot to that dB.
I don't connect directly to the SQL source as it only retains 30 days of data on a rolling basis.
 
Upvote 0
The data comes from an SQL BD, but I can only export that one week at a time into excel (400k rows of data). That gets compiled into access so I can get YTD records, and then I connect PowerPivot to that dB.
I don't connect directly to the SQL source as it only retains 30 days of data on a rolling basis.
I'm at a loss. I have the same data, and the DAX formula
Power Query:
=HOUR(ContHist[Custom])*3600+MINUTE(ContHist[Custom])*60+SECOND(ContHist[Custom])
works for me! The formula is for Calculated Column 1.

1671730192344.png
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top