Forum Discussion

Swalker's avatar
Swalker
Frequent Visitor
3 years ago
Solved

in-column replacement "error " using try otherwise and #datetime(YY,MM,DD)

Hi , I have a table with Date, FinancialPeriod (= month) and FinancialYear from entries. The accounting software uses FP and FY as key parameters Some Dates are wrongly entered : they do not match...
  • HotChilli's avatar
    3 years ago

    A few alterations should fix it:

    #"step" = Table.AddColumn(#"Added Custom1", "AltDate1", each try #date([FinancialYear], [FinancialPeriod], [Day]) 
    otherwise   Date.EndOfMonth(#date([FinancialYear], [FinancialPeriod], 1)))

    This will put the end of the month in but you can change it if you want to stick with the (subtract 3 days) method

  • Swalker's avatar
    Swalker
    3 years ago

    Many thanks HotChilli for this elegant solution !