Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DateAdd issue

Hello I have a set of dates that I want to add 1 years too, Here is the Dax     Iit works fine untill I get to 2023 See below   Any Ideas?      
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  Anonymous ,

     

    Agree with edhans , please use EDATE() to add years.

    Or you could use Date.AddYears() to a custom column in Power Query:

    Date.AddYears([Date],1)

    And then change its type to Date. Below is the whole M syntax:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VczBDYAwDATBXvxGOp+tJFBL5P7bIEiA4+c8ducUUyM66BLHKyo4Cp0fDSxyuKYaemJsl5URVxH/zp9nwtF2sKdOmETc", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Date.AddYears([Date],1)),
        #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type date}})
    in
        #"Changed Type1"

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.