Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bbrauer100
New Member

Time to Duration conversion throws an error.

I'm trying to convert time of day to duration in order to perform summary calculations.  However, when I try to convert time to duration in Query Editor the following error occurs:

 

 

DataFormat.Error: We couldn't convert to Duration.
Details:
    1:11:55 AM

Seems pretty straight forward, so what am I missing?

15 REPLIES 15
BAWard
New Member


I have the exact same problem.  The column of input is formatted as date/time, and represents durations in hours:minutes. 

let
    Source = Excel.Workbook(File.Contents("C:\Users\Me\Documents\Test_Duration_Format.xlsx"), null, true),
    TestColumn_Table = Source{[Item="TestColumn",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(TestColumn_Table,{{"TestDuration", type duration}})
in
    #"Changed Type"

with the following input:

 

Input.JPG

Forum didn't accept screen shot in my original reply, and would not let me edit it after it  was  submitted, so here is the sample input.  Hopefully it woks this time.

 

 

 

 

 

I have the exact same problem.

 

Did you find anything that worked?

 

Thank you

J

wonga
Continued Contributor
Continued Contributor

@BAWard@bbrauer100@jagostinhoCT You need to ensure the format of the cells is "Text" first. This can be done either in Excel by highlighting the cells -> Format Cells -> Text, or in Power BI Query Editor by highlighting the column and going to the ribbon -> Transform -> Data Type -> Text. Then you can add a "calculated column" in Power BI Query Editor using the following:

 

CustomColumn = Duration.FromText([Duration])

 

You can then extract your desired duration from that new custom column such as: total minutes, total hours, total seconds, etc.

 

In my experience, I've found the easiest way to use duration is by subtracting an end time from a start time and then converting it to the desired duration. Hope this helps, thanks.

 

 

Converted to text a few times in the PQ editor. Didn't work in any scenario. Tried each of the following and all results in Duration errors:

1. Duplicated values column, changed format to Text
2. Added a column with MCode using Duration.From
3. Added a column with MCode using Duration.FromText

all produced the same.

But if it is converted to text how can it then be used on graphs?

Say, for instance, where one wants to graph total amount of time spent on a project?

wonga
Continued Contributor
Continued Contributor

@jagostinhoCT

 

Well in that case, you would have start times and end times right? The scenario that was presented here was just a table of durations.

 

Ideally, if you were tracking the progress of a project you would start off with a start date/time and end date/time. These would be considered as DateTime values in Power BI.

 

From the query editor, you would be able to calculate the duration of the project by doing [End Time] - [Start Time] and then converting that value into the duration you want. Once you get all that data sorted out, then you would use the appropriate visual to display those values.

 

Possible visuals would be Gannt or horizontal bar chart.

 

If you can provide me with a sample dataset, I'll see what I can mock up to give you a better idea of how to do it.

@wonga

 

See a sample of the date I want to use below.

 

Thank you

 

 

ProjectIDTaskDescriptionStart dateStart timeEnd dateEnd timeDurationTags
018/CADAudits Dashboard08/04/201616:41:1308/04/201617:39:1200:57:59Cont. Impr. - R&D
018/CADRailings CPD Preparation12/09/201416:00:0812/09/201417:23:2001:23:12Cont. Impr. - Training / Induction
018/CADTask review and Management10/07/201513:43:2610/07/201513:44:0000:00:34Office
018/CADCPD - The Series07/04/201610:51:0507/04/201610:59:4500:08:40Cont. Impr. - Training / Induction
018/CADRevit Training Sessions preparation11/09/201409:09:2511/09/201411:34:3102:25:06Cont. Impr. - Training / Induction
018/CADCPD on Views preparation13/04/201513:25:1413/04/201515:26:3602:01:22Cont. Impr. - Training / Induction
018/CADRevit training sessions outline and preparation27/10/201415:20:5027/10/201415:27:5400:07:04Cont. Impr. - Training / Induction
018/CADTask review and Management14/07/201509:38:3914/07/201509:43:1600:04:37Office
018/CADCT Template25/09/201408:56:4625/09/201410:08:5301:12:07Cont. Impr. - Standards / Guides
018/CADTask review and Management29/04/201517:29:4029/04/201517:30:3800:00:58Office procedures
018/CADAudits Dashboard08/04/201616:09:3208/04/201616:17:2400:07:52Cont. Impr. - R&D
018/CADLibrary Management26/08/201415:48:2926/08/201416:45:5600:57:27Cont. Impr. - Templates / Families
018/CADBIM Conference report13/10/201412:55:1213/10/201413:06:3300:11:21Cont. Impr. - Conferences & Workshops
018/CADCPD Feedback form fill out11/09/201417:11:5711/09/201417:29:0600:17:09Cont. Impr. - Training / Induction
018/CADBEP Template update12/05/201511:25:3512/05/201511:32:1700:06:42Cont. Impr. - Templates / Families
018/CADTraining area setup15/09/201417:00:3315/09/201417:31:4800:31:15Cont. Impr. - Training / Induction
018/CADHTG Packaging and uploading to the Hub01/05/201511:07:4101/05/201512:03:3000:55:49Cont. Impr. - Standards / Guides
018/CADRailings CPD Preparation18/09/201413:45:5118/09/201417:32:0803:46:17Cont. Impr. - Training / Induction
018/CADCPD Curtain Walls17/07/201511:51:3517/07/201512:31:5600:40:21Cont. Impr. - Training / Induction
018/CADstaff induction02/02/201515:16:3702/02/201515:22:1200:05:35Cont. Impr. - Training / Induction
018/CADCT Template update25/06/201514:00:3325/06/201516:12:5802:12:25Cont. Impr. - Templates / Families
018/CADCT Template CPD setup13/02/201515:53:3013/02/201516:13:5700:20:27Cont. Impr. - Training / Induction
018/CADProject Workflow Checklist02/06/201516:02:1402/06/201516:06:3700:04:23Cont. Impr. - Standards / Guides
018/CADRevit training sessions outline and preparation20/11/201416:51:0020/11/201417:15:0000:24:00Cont. Impr. - Training / Induction
018/CADBIM Meeting with David25/02/201516:53:2025/02/201517:06:2900:13:09BIM Management Meeting
018/CADBIM Glue and Collaboration on Simon Blakey's pc05/04/201609:05:3305/04/201612:04:3102:58:58Cont. Impr. - IT
018/CADLibrary Management26/08/201414:38:5626/08/201414:48:5100:09:55Cont. Impr. - Templates / Families
018/CADView Templates transfer problem report to Autodesk06/10/201411:41:2006/10/201413:13:0501:31:45BIM Project Support
018/CADRevit Training Sessions preparation10/09/201414:07:0710/09/201414:18:4600:11:39Cont. Impr. - Training / Induction
018/CADSkills Self Assessment update09/12/201414:32:0709/12/201414:36:3700:04:30Cont. Impr. - Training / Induction
018/CADIssue management software search11/09/201414:27:5511/09/201416:04:3001:36:35Cont. Impr. - R&D
018/CADUpdate Running Projects to current Template Version23/04/201516:05:0823/04/201516:34:2400:29:16Reviews / Surveys / Assessments
018/CADRevit titleblocks for Moscow12/09/201412:02:2212/09/201413:02:3501:00:13Cont. Impr. - Templates / Families
018/CADBDSU2015Ult LON Deployment09/06/201513:53:4909/06/201513:57:4100:03:52Cont. Impr. - IT
018/CADView Templates28/08/201411:56:4128/08/201412:51:3800:54:57Cont. Impr. - Standards / Guides
018/CADCT Template update20/03/201509:44:3920/03/201509:51:3800:06:59Cont. Impr. - Standards / Guides
018/CADCT Template setup24/10/201410:57:5324/10/201413:38:3002:40:37Cont. Impr. - Standards / Guides
018/CADBDSU2015 MAN Deployment update01/05/201515:51:2001/05/201517:06:0901:14:49Cont. Impr. - IT
018/CADRevit training sessions outline and preparation29/10/201408:45:0029/10/201409:46:0001:01:00Cont. Impr. - Training / Induction
018/CADMarketing CT BIM Image20/01/201513:01:1120/01/201513:01:1200:00:01Cont. Impr. - Marketing
018/CADRender templates01/09/201414:40:5201/09/201415:06:4700:25:55Cont. Impr. - Standards / Guides
018/CADnew starters followup20/07/201510:58:3720/07/201511:03:4900:05:12Cont. Impr. - Training / Induction
018/CADRAM install for A630-BPT pcs07/11/201410:02:2907/11/201410:32:3600:30:07Cont. Impr. - IT
018/CADBIM Review Template14/05/201510:02:0314/05/201510:09:1400:07:11Cont. Impr. - Templates / Families
018/CADCT Template24/09/201410:01:4124/09/201413:06:5503:05:14Cont. Impr. - Standards / Guides
018/CADCT Template update25/06/201516:19:0225/06/201516:31:0200:12:00Cont. Impr. - Templates / Families
018/CADCT Template25/09/201413:34:3825/09/201415:32:1701:57:39Cont. Impr. - Standards / Guides
018/CADSelf Assessment Record update06/03/201516:07:0906/03/201516:16:5900:09:50Cont. Impr. - Training / Induction
018/CADRevit training sessions outline and preparation19/11/201409:52:4219/11/201410:16:1000:23:28Cont. Impr. - Training / Induction
018/CADTask review and Management30/06/201515:55:5530/06/201516:05:0900:09:14Office
018/CADCT Titleblocks29/09/201416:25:3429/09/201417:14:2800:48:54Cont. Impr. - Templates / Families
018/CADLoretta Collins BIM CAD Induction23/02/201512:36:5223/02/201513:06:2000:29:28Cont. Impr. - Training / Induction
018/CADRevit Training Sessions preparation04/09/201414:25:5504/09/201417:30:3703:04:42Cont. Impr. - Training / Induction
018/CADBEP Template update14/04/201509:21:3314/04/201509:30:5700:09:24Cont. Impr. - Standards / Guides
018/CADRailings CPD Preparation01/10/201413:58:3501/10/201414:47:1500:48:40Cont. Impr. - Training / Induction
018/CADAudits Dashboard08/04/201615:11:2608/04/201615:35:4500:24:19Cont. Impr. - R&D
018/CADLibrary Management26/08/201412:02:0926/08/201412:06:5000:04:41Cont. Impr. - Templates / Families
018/CADReading ct documentation11/08/201409:00:0011/08/201417:30:0008:30:00Cont. Impr. - Training / Induction
018/CADRevit training sessions outline and preparation01/12/201411:58:3901/12/201412:24:4900:26:10Cont. Impr. - Training / Induction
018/CADRevit software tweak or cleanup03/10/201417:22:2103/10/201417:27:1300:04:52Cont. Impr. - IT
018/CADSmart Browser Setup23/04/201515:21:4223/04/201515:40:2500:18:43Cont. Impr. - R&D
018/CADLibrary Management26/08/201417:31:2426/08/201417:48:1400:16:50Cont. Impr. - Templates / Families
018/CADModel Review tool29/04/201517:30:4629/04/201517:47:4200:16:56Cont. Impr. - R&D
018/CADBIM International Conference, Lisbon09/10/201409:00:0009/10/201418:00:0009:00:00Cont. Impr. - Conferences & Workshops
018/CADTask review and Management22/05/201509:30:5622/05/201509:45:0100:14:05Office
018/CADCT Template setup14/10/201410:32:3114/10/201410:32:3800:00:07Cont. Impr. - Standards / Guides
018/CADHotdesk setup11/12/201412:51:0011/12/201413:15:0000:24:00Cont. Impr. - IT
018/CADCT Template setup15/10/201413:11:3015/10/201413:18:3200:07:02Cont. Impr. - Standards / Guides
018/CADBDSU2015MAN02 Deployment ACAD update11/05/201511:44:4411/05/201511:57:2600:12:42Cont. Impr. - IT
018/CADRevit training sessions outline and preparation15/12/201415:31:3815/12/201418:02:2802:30:50Cont. Impr. - Training / Induction
018/CADRevit training sessions outline and preparation16/12/201416:07:0016/12/201418:36:3502:29:35Cont. Impr. - Training / Induction
018/CADBPG Formulas for everyday usage12/09/201414:23:2512/09/201415:49:4301:26:18Cont. Impr. - Standards / Guides
018/CADBIM Management meeting with David Wood10/06/201509:30:3710/06/201510:25:5800:55:21BIM Management Meeting
018/CADRevit training sessions outline06/01/201510:37:3206/01/201512:06:5001:29:18Cont. Impr. - Training / Induction
018/CAD2015 Deployment18/03/201509:34:5718/03/201510:01:4400:26:47Cont. Impr. - IT
018/CADCT Template setup22/10/201410:22:1222/10/201413:06:4002:44:28Cont. Impr. - Standards / Guides
018/CADBEP Template update12/05/201515:00:1512/05/201515:14:0400:13:49Cont. Impr. - Templates / Families
018/CADDrawing Graphic Comparison for View Template Setting28/08/201416:09:2328/08/201417:53:2001:43:57Cont. Impr. - Standards / Guides
018/CADBIM Manager's meeting preparation03/03/201513:46:3303/03/201514:49:2701:02:54BIM Management Meeting
018/CADRevit skills self assessmente - training class update14/01/201515:10:5614/01/201515:43:4400:32:48Cont. Impr. - Training / Induction
018/CADReviewing Projects BIM Reviews status12/06/201514:47:1212/06/201514:58:2000:11:08BIM Management
018/CADDrawing Graphic Comparison for View Template Setting29/08/201417:07:4329/08/201417:19:1200:11:29Cont. Impr. - Standards / Guides
018/CADBIM Review Template27/04/201512:26:3227/04/201512:37:5300:11:21Cont. Impr. - Templates / Families
018/CADRevit training sessions outline and preparation29/10/201413:36:0029/10/201416:09:3602:33:36Cont. Impr. - Training / Induction
018/CADHTG Model Validation08/05/201509:48:0408/05/201510:05:3600:17:32Cont. Impr. - Standards / Guides
018/CADRevit Skills Self Assessment Update25/03/201510:34:0025/03/201511:34:0001:00:00Reviews / Surveys / Assessments
018/CADCPD on Views preparation13/04/201512:22:5113/04/201512:55:2800:32:37Cont. Impr. - Training / Induction
018/CADCT Template22/09/201410:19:1122/09/201411:51:0801:31:57Cont. Impr. - Standards / Guides
018/CADTask review and Management02/06/201515:52:1102/06/201515:54:3100:02:20Office
018/CADModel Audit Template revision06/11/201417:00:2306/11/201417:35:2000:34:57Reviews / Surveys / Assessments
018/CADKiwi Bonus tools price29/01/201512:04:3829/01/201512:25:2100:20:43Cont. Impr. - R&D
018/CADKnowledge Smart test29/01/201516:54:3429/01/201518:01:2401:06:50Cont. Impr. - Training / Induction
018/CADBristol BDSU2014 Deployment18/05/201517:49:5618/05/201518:11:2200:21:26Cont. Impr. - IT
018/CADCT Template24/09/201409:35:2024/09/201409:52:5100:17:31Cont. Impr. - Standards / Guides
wonga
Continued Contributor
Continued Contributor

@jagostinhoCT Can you provide a dataset sample with proper formatting? For example your start date and end dates are not consistent in formatting. Some of them are formatted correctly in mm/dd/yyyy whereas others are in a weird format like dd/mm/yyyy.

 

@wonga

I was unable to find how to attach an Excel file.

 

The dates are all formatted as dd/mm/yyyy. 

 

I have sorted them by Start Date.

Does the one below work?

 

ProjectIDTaskDescriptionStart dateStart timeEnd dateEnd timeDurationTags
018/CADLibrary Management26/08/201415:48:2926/08/201416:45:5600:57:27Cont. Impr. - Templates / Families
018/CADRevit Training Sessions preparation11/09/201409:09:2511/09/201411:34:3102:25:06Cont. Impr. - Training / Induction
018/CADCPD Feedback form fill out11/09/201417:11:5711/09/201417:29:0600:17:09Cont. Impr. - Training / Induction
018/CADRailings CPD Preparation12/09/201416:00:0812/09/201417:23:2001:23:12Cont. Impr. - Training / Induction
018/CADTraining area setup15/09/201417:00:3315/09/201417:31:4800:31:15Cont. Impr. - Training / Induction
018/CADRailings CPD Preparation18/09/201413:45:5118/09/201417:32:0803:46:17Cont. Impr. - Training / Induction
018/CADCT Template25/09/201408:56:4625/09/201410:08:5301:12:07Cont. Impr. - Standards / Guides
018/CADBIM Conference report13/10/201412:55:1213/10/201413:06:3300:11:21Cont. Impr. - Conferences & Workshops
018/CADRevit training sessions outline and preparation27/10/201415:20:5027/10/201415:27:5400:07:04Cont. Impr. - Training / Induction
018/CADCPD on Views preparation13/04/201513:25:1413/04/201515:26:3602:01:22Cont. Impr. - Training / Induction
018/CADTask review and Management29/04/201517:29:4029/04/201517:30:3800:00:58Office procedures
018/CADHTG Packaging and uploading to the Hub01/05/201511:07:4101/05/201512:03:3000:55:49Cont. Impr. - Standards / Guides
018/CADBEP Template update12/05/201511:25:3512/05/201511:32:1700:06:42Cont. Impr. - Templates / Families
018/CADTask review and Management10/07/201513:43:2610/07/201513:44:0000:00:34Office
018/CADTask review and Management14/07/201509:38:3914/07/201509:43:1600:04:37Office
018/CADCPD Curtain Walls17/07/201511:51:3517/07/201512:31:5600:40:21Cont. Impr. - Training / Induction
018/CADCPD - The Series07/04/201610:51:0507/04/201610:59:4500:08:40Cont. Impr. - Training / Induction
018/CADAudits Dashboard08/04/201616:41:1308/04/201617:39:1200:57:59Cont. Impr. - R&D
018/CADAudits Dashboard08/04/201616:09:3208/04/201616:17:2400:07:52Cont. Impr. - R&D
wonga
Continued Contributor
Continued Contributor

@jagostinhoCT I've made a PBIX file but I can't get it to you yet. I need to find a way to upload it, thanks.

 

EDIT: I was able to upload it to the Power BI Community: http://community.powerbi.com/oxcrx34285/attachments/oxcrx34285/DesignMakeover052016/5/2/sample_ds.pb...

 

I had to reformat some of the start date and time data in an excel file, but you should be able to figure out how I got the calculated columns. Let me know if this is what you were looking for or at least if I was on the right track, thanks.

 

@wonga

Even though I am not currently looking for a Gantt the new modelling works.

 

At the moment, I am trying to learn how to get sums of duration for specific tags. As per image below.

 

An error ensues when trying to edit the queries so I cannot see the steps taken. Tried to copy/paste the data into an excel and replace the source but it breaks as well. Would it be possible to ask for the excel you used? (BTW, how can one include an attachment?)

 

So, it seems that I may need to have different calculated columns to suffice different reporting needs. I may need a single column where it converts all into minutes and another one was Text for splitting time into mins, hours, days.

 

Thank you very much for your help

 

Tags and Duration.png

 

wonga
Continued Contributor
Continued Contributor

Hey @jagostinhoCT,

 

See if you can access this Google Drive documents: https://drive.google.com/open?id=0B-bZzUsHzLUnZ3ZUY05PQ1gwVmM

 

I made an edit to the queries, made a mistake where it's not getting the total minutes or hours and only extracting the minutes or hours part of the overall duration. Look at page 2 of the PBIX file and see if it's what you are looking for. 

 

Thanks.

Hello @wonga

 

I apologise for the late reply.

 

The file you sent me seems to be it.

 

Thank you very much for yout time and help.

 

Kind regards,

Joaquim

Greg_Deckler
Super User
Super User

Can you post sample data and your formula? Basically impossible to give you any meaningful feedback otherwise.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.