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! Learn more

Reply
Anonymous
Not applicable

Need Help : Expression Error: We cannot apply field access to the type function

I am trying to create a column with M- Query to convert a time field in the text to regular time in addition to converting it from UTC to IST. Using the query underneath. However, getting an error of "Expression Error: We cannot apply field access to the type function ". What am I doing wrong.

 

 

 

 

Table.AddColumn(#"Changed Type", "Dep Time (IST)", each if(Text.Length[#"Dept Time[UTC]"]=4) then Text.Start([#"Dept Time[UTC]"],2)&":"&Text.End([#"Dept Time[UTC]"],2) else if(Text.Length[#"Dept Time[UTC]"]=3) then Text.Start([#"Dept Time[UTC]"],1)&":"&Text.End([#"Dept Time[UTC]"],2) else if(Text.Length[#"Dept Time[UTC]"]=2) then "00"&":"&Text.End([#"Dept Time[UTC]"],2) else "00:00")

 

 

 

 

uutsav0101_0-1604641785804.png

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

Table.AddColumn(#"Changed Type", "Dep Time (IST)", each if Text.Length([#"Dept Time[UTC]"])=4 then Text.Start([#"Dept Time[UTC]"],2)&":"&Text.End([#"Dept Time[UTC]"],2) else if Text.Length([#"Dept Time[UTC]"])=3 then Text.Start([#"Dept Time[UTC]"],1)&":"&Text.End([#"Dept Time[UTC]"],2) else if Text.Length([#"Dept Time[UTC]"])=2 then "00"&":"&Text.End([#"Dept Time[UTC]"],2) else "00:00")

View solution in original post

3 REPLIES 3
PhilipTreacy
Super User
Super User

Hi @Anonymous 

I don't see how the accepted solution converts to IST as you asked for?

If all you wanted was a text string to represent the UTC time all you need is this

= Table.AddColumn(#"Changed Type", "Custom", each Text.Insert(Text.PadStart([#"Dept Time[UTC]"], 4, "0"),2,":"))

Phil 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


wdx223_Daniel
Super User
Super User

Table.AddColumn(#"Changed Type", "Dep Time (IST)", each if Text.Length([#"Dept Time[UTC]"])=4 then Text.Start([#"Dept Time[UTC]"],2)&":"&Text.End([#"Dept Time[UTC]"],2) else if Text.Length([#"Dept Time[UTC]"])=3 then Text.Start([#"Dept Time[UTC]"],1)&":"&Text.End([#"Dept Time[UTC]"],2) else if Text.Length([#"Dept Time[UTC]"])=2 then "00"&":"&Text.End([#"Dept Time[UTC]"],2) else "00:00")
PhilipTreacy
Super User
Super User

Hi @Anonymous 

This M code will do it.

Here's a sample PBIX file containing the code.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQwNlWK1YlWMjIwNQAzoHxjAwjX1BhCWxgC6VgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Dept Time[UTC]" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Text.PadStart([#"Dept Time[UTC]"], 4, "0")),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type time}}),
    #"Added Custom1" = Table.AddColumn(#"Changed Type", "Dept Time[IST]", each [Custom] + #duration(0, 5, 30, 0))
in
    #"Added Custom1"

 

utc-to-ist.png

Phil 


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


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.