The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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"
Solved! Go to Solution.
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]
Thank you, Sir!! Much appreciated. Worked like a charm.
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]