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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors