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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
EmQuery
Frequent Visitor

Expression.Error: We cannot apply field access to the type Duration

Still expanding on learning M.

 

I have come across an issue I can't resolve.

 

My original data has Duration values, but some of them start with a colon (":"). In order to fix that, I create a formula to remove the colon. When I try to create a final column to pull in the final amounts, I get error "Expression.Error: We cannot apply field access to the type Duration". I am at a loss of what else to try. Any advise is highly appreciated. Thank you!

 

Code is:

let

    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],

    #"Removed Top Rows" = Table.Skip(Source,2),

    #"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),

    #"Removed Other Columns" = Table.SelectColumns(#"Promoted Headers",{"Agent Name", "Login ID", "Login Time", "Logout Time", "Login Duration"}),

 

    //Correct the values starting with Colon

    #"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Duration Fix", each if Text.Start([Login Duration], 1) = ":" then "00:"&Text.End([Login Duration], Text.Length([Login Duration]) -1) else [Login Duration]),

 

   // Try Duration Fix

    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Try Duration Fix", each try [Duration Fix]),

    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"Agent Name", type text}, {"Login ID", Int64.Type}, {"Login Time", type time}, {"Logout Time", type time}, {"Duration Fix", type duration}, {"Login Duration", type duration}}),

    #"Added Custom3" = Table.AddColumn(#"Changed Type", "Final Duration", each if [Try Duration Fix][HasError] then [Login Duration] else [Duration Fix][Value])

in

    #"Added Custom3"

 

thumbnail_image001.png

1 ACCEPTED SOLUTION
artemus
Microsoft Employee
Microsoft Employee

You have: [Duration Fix][Value]

It should be:

[Try Duration Fix][Value]

or

[Duration Fix]

 

P.S. This can be simplified to 

try [Duration Fix] otherwise [Login Duration]

View solution in original post

2 REPLIES 2
EmQuery
Frequent Visitor

Thank you, Sir!! Much appreciated. Worked like a charm.

artemus
Microsoft Employee
Microsoft Employee

You have: [Duration Fix][Value]

It should be:

[Try Duration Fix][Value]

or

[Duration Fix]

 

P.S. This can be simplified to 

try [Duration Fix] otherwise [Login Duration]

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors