Forum Discussion

arnaudmanir's avatar
arnaudmanir
Frequent Visitor
3 years ago
Solved

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

Hello. Will someone please tell me what's wrong with my formula?  = Table.TransformColumns( #"Changed Type",{"ADVANCE_DATE (YYYYMMDD)", each Text.Combine({Date.ToText([#"ADVANCE_DATE (YYYYMMDD)"], "...
  • m_dekorte's avatar
    3 years ago

    Hi arnaudmanir,

    Give this a go instead. You can copy the full code into a new blank query

    let
        Source = Table.FromColumns(
            {{#date(2023, 5, 7), #date(2023, 10, 5)}},
            {"ADVANCE_DATE (YYYYMMDD)"}
        ),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ADVANCE_DATE (YYYYMMDD)", type date}}),
        Transform = Table.TransformColumns( #"Changed Type",
        {
            {"ADVANCE_DATE (YYYYMMDD)", each Text.Combine( 
                { 
                    Date.ToText( _, [Format="yyyy"]), 
                    Date.ToText( _, [Format="MM"]), 
                    Date.ToText( _, [Format="dd"])
                }), type text
            }
        }
    )
    in
        Transform

    Ps. If this helps solve your query please mark this post as Solution, thanks!