Forum Discussion

ahmadov_10's avatar
ahmadov_10
Helper II
4 years ago
Solved

We cannot convert the value #date to type Function

Hello Experts, in Power Query editor i need to configure a StartDate and EndDate  I maked this code and the formulas StartDate and EndDate works fine : let source .....  StartDate = Date.AddMont...
  • v-kkf-msft's avatar
    4 years ago

    Hi ahmadov_10 ,

     

    You are missing "each" in this step, and it will throw an error "We cannot convert the value #date to type Function".

    #"Addedend" = Table.AddColumn(#"Addedstart", "EndDate", EndDate)

     

    Please try the following code.

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWcgKTzmDSRSk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
        StartDate = Date.AddMonths(Date.StartOfMonth(DateTime.Date(DateTime.FixedLocalNow())), -13), // 01/06/2021
        EndDate = Date.AddMonths(Date.EndOfMonth(DateTime.Date(DateTime.FixedLocalNow())), -1), // 30/06/2022
        #"Addedstart" = Table.AddColumn(#"Changed Type", "StartDate", each Date.ToText(StartDate)),
        #"Addedend" = Table.AddColumn(#"Addedstart", "EndDate", each EndDate)
    in
        #"Addedend"

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.