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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
caseyatdrake
New Member

Time into duration - text not working, excel/PBI both issuing errors

Hey I'm working on a fun project around half marathon races. Problem is my race data is showing at time of day rather than duration. I've tried converting to text, multiplying out into total minutes, and such within both Bi and excel but neither is working. there are 4 columns split 1, 2, 3, and total time but all are throwing error and messing everyhing up - any help or thoughts on what i can do? 

 

Thanks!

CC

 

caseyatdrake_1-1659897030670.png

 

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @caseyatdrake 
Here is a sample file with the solution https://www.dropbox.com/t/gyhXd49lugDwVccw

let
    Source = Excel.Workbook(File.Contents("C:\XXX\XXX\XXX\XXX\XXX\Community 324.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Split 1", type datetime}, {"Split 2", type datetime}, {"Split 3", type datetime}, {"Overall Time", type datetime}}),
    #"Added Split1" = Table.AddColumn(#"Changed Type", "Split1", each Time.Second([Split 1]) + Time.Minute([Split 1]) * 60 +  Time.Hour([Split 1]) * 3600 ),
    #"Added Split2" = Table.AddColumn(#"Added Split1", "Split2", each Time.Second([Split 2]) + Time.Minute([Split 2]) * 60 +  Time.Hour([Split 2]) * 3600 ),
    #"Added Split3" = Table.AddColumn(#"Added Split2", "Split3", each Time.Second([Split 3]) + Time.Minute([Split 3]) * 60 +  Time.Hour([Split 3]) * 3600 ),
    #"Added Total" = Table.AddColumn(#"Added Split3", "Total Time", each Time.Second([Overall Time]) + Time.Minute([Overall Time]) * 60 +  Time.Hour([Overall Time]) * 3600 ),
    #"Removed Columns" = Table.RemoveColumns(#"Added Total",{"Split 1", "Split 2", "Split 3", "Overall Time"})
in
    #"Removed Columns"

View solution in original post

5 REPLIES 5
tamerj1
Super User
Super User

Hi @caseyatdrake 
Here is a sample file with the solution https://www.dropbox.com/t/gyhXd49lugDwVccw

let
    Source = Excel.Workbook(File.Contents("C:\XXX\XXX\XXX\XXX\XXX\Community 324.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Split 1", type datetime}, {"Split 2", type datetime}, {"Split 3", type datetime}, {"Overall Time", type datetime}}),
    #"Added Split1" = Table.AddColumn(#"Changed Type", "Split1", each Time.Second([Split 1]) + Time.Minute([Split 1]) * 60 +  Time.Hour([Split 1]) * 3600 ),
    #"Added Split2" = Table.AddColumn(#"Added Split1", "Split2", each Time.Second([Split 2]) + Time.Minute([Split 2]) * 60 +  Time.Hour([Split 2]) * 3600 ),
    #"Added Split3" = Table.AddColumn(#"Added Split2", "Split3", each Time.Second([Split 3]) + Time.Minute([Split 3]) * 60 +  Time.Hour([Split 3]) * 3600 ),
    #"Added Total" = Table.AddColumn(#"Added Split3", "Total Time", each Time.Second([Overall Time]) + Time.Minute([Overall Time]) * 60 +  Time.Hour([Overall Time]) * 3600 ),
    #"Removed Columns" = Table.RemoveColumns(#"Added Total",{"Split 1", "Split 2", "Split 3", "Overall Time"})
in
    #"Removed Columns"
tamerj1
Super User
Super User

Hi @caseyatdrake 

please provide an example of what should be the expected result. 

When I change to text (i can somehow send the file) it removes the seconds. I've tried to extract or split the column but it always removes the seconds. The other issue with extracting is that due to the fact some of the race times are 49 minutes and 33 seconds and some are over 1 hour 12 minutes and 33 seconds the time that is showing up makes it impossible to extract. 

@caseyatdrake 

Please share a sample file

I'd accept either of: 

 

Split 1                     Split 2               Split 3           Overall Time

15:29                      30:33                 49:12             1:04:26           Essentially removing the "12" and "AM" on the row one example from above. 

929                         1833                  2952              3866          = this would be converting everything to seconds so I could perform various data measurements etc. 

 

Thanks!

CC

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.